diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa')
470 files changed, 0 insertions, 62282 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUi.java deleted file mode 100644 index 44e2db91fc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUi.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui; - -import java.util.Iterator; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; -import org.eclipse.swt.widgets.Composite; - -/** - * This interface is to be implemented by a JPA vendor to provide extensions to - * JPA UI functionality. This is intended to work in conjunction with a core - * JPA platform ({@link JpaPlatform}) implementation with the same ID. - * <p> - * Any implementation should be <em>stateless</em> in nature. - * <p> - * The "generic" extension supplies UI for the core platform extension with the same - * ID. - * - * See the extension point: org.eclipse.jpt.jpa.ui.jpaPlatform - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaPlatformUi -{ - // ********** navigator provider ********** - - /** - * Return the {@link JpaNavigatorProvider} for this platform, - * which determines Project Explorer content and look - */ - JpaNavigatorProvider getNavigatorProvider(); - - - // ********** structure providers ********** - - /** - * Return a structure provider for the specified JPA file. - */ - JpaStructureProvider getStructureProvider(JpaFile jpaFile); - - - // ********** details providers ********** - - JpaDetailsPage<? extends JpaStructureNode> buildJpaDetailsPage( - Composite parent, - JpaStructureNode structureNode, - WidgetFactory widgetFactory); - - - // ********** file ui definitions ********** - - /** - * Return a resource ui definition for the specified resource type. - */ - ResourceUiDefinition getResourceUiDefinition(JptResourceType resourceType); - - - // ********** type mappings ********** - - JpaComposite buildTypeMappingComposite( - JptResourceType resourceType, - String mappingKey, - Composite parent, - PropertyValueModel<TypeMapping> mappingHolder, - WidgetFactory widgetFactory); - - DefaultMappingUiDefinition<PersistentType, ? extends TypeMapping> - getDefaultTypeMappingUiDefinition(JptResourceType resourceType); - - Iterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>> - typeMappingUiDefinitions(JptResourceType resourceType); - - - // ********** attribute mappings ********** - - JpaComposite buildAttributeMappingComposite( - JptResourceType resourceType, - String mappingKey, - Composite parent, - PropertyValueModel<AttributeMapping> mappingHolder, - WidgetFactory widgetFactory); - - DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping> - getDefaultAttributeMappingUiDefinition(JptResourceType resourceType, String mappingKey); - - Iterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>> - attributeMappingUiDefinitions(JptResourceType resourceType); - - - // ********** entity generation ********** - - void generateEntities(JpaProject project, IStructuredSelection selection); - - - // ********** DDL generation ********** - - void generateDDL(JpaProject project, IStructuredSelection selection); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUiFactory.java deleted file mode 100644 index 02efd79aae..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUiFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui; - -/** - * This interface is to be implemented by a JPA vendor to build a JpaPlatformUi. - * - * See the extension point: org.eclipse.jpt.jpa.ui.jpaPlatform - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaPlatformUiFactory -{ - JpaPlatformUi buildJpaPlatformUi(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUiProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUiProvider.java deleted file mode 100644 index a1a064d1b4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JpaPlatformUiProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui; - -import java.util.ListIterator; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; - -/** - * This interface is to be implemented by a JPA vendor to provide extensions to - * JPA UI functionality. This is intended to work in conjunction with a core - * JPA platform ({@link JpaPlatform}) implementation with the same ID. - * <p> - * Any implementation should be <em>stateless</em> in nature. - * <p> - * The "generic" extension supplies UI for the core platform extension with the same - * ID. - * - * See the extension point: org.eclipse.jpt.jpa.ui.jpaPlatformUis - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaPlatformUiProvider -{ - /** - * Return the details providers that apply to this platform. - */ - ListIterator<JpaDetailsProvider> detailsProviders(); - - /** - * Return the resource ui definitions that apply to this platform. - */ - ListIterator<ResourceUiDefinition> resourceUiDefinitions(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiPlugin.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiPlugin.java deleted file mode 100644 index 5bda78f05b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiPlugin.java +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * Dali UI plug-in. - * <p> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -@SuppressWarnings("nls") -public class JptJpaUiPlugin - extends AbstractUIPlugin -{ - private final Listener focusListener; - - - // ********** constants ********** - - /** - * The plug-in identifier of JPA UI support (value {@value}). - */ - public static final String PLUGIN_ID = "org.eclipse.jpt.jpa.ui"; - public static final String PLUGIN_ID_ = PLUGIN_ID + '.'; - - private static final String FOCUS_DATA_KEY = PLUGIN_ID_ + "focus"; - private static final Object FOCUS_DATA = new Object(); - - - // ********** singleton ********** - - private static JptJpaUiPlugin INSTANCE; - - /** - * Returns the singleton JPT UI plug-in. - */ - public static JptJpaUiPlugin instance() { - return INSTANCE; - } - - - // ********** logging ********** - - public static void log(IStatus status) { - INSTANCE.getLog().log(status); - } - - public static void log(String msg) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, null)); - } - - public static void log(Throwable throwable) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, throwable.getLocalizedMessage(), throwable)); - } - - - // ********** images ********** - - /** - * Return an image descriptor for the specified <code>.gif<code> - * file in the icons folder. - */ - public static ImageDescriptor getImageDescriptor(String key) { - if ( ! key.startsWith("icons/")) { - key = "icons/" + key; - } - if ( ! key.endsWith(".gif")) { - key = key + ".gif"; - } - return imageDescriptorFromPlugin(PLUGIN_ID, key); - } - - /** - * Return an image for the specified <code>.gif<code> - * file in the icons folder. - */ - //TODO we are using the ImageRegistry here and storing all our icons for the life of the plugin, - //which means until the workspace is closed. This is better than before where we constantly - //created new images. Bug 306437 is about cleaning this up and using Local Resource Managers - //on our views so that closing the JPA perspective would mean our icons are disposed. - public static Image getImage(String key) { - ImageRegistry imageRegistry = instance().getImageRegistry(); - Image image = imageRegistry.get(key); - if (image == null) { - imageRegistry.put(key, getImageDescriptor(key)); - image = imageRegistry.get(key); - } - return image; - } - - - // ********** construction ********** - - public JptJpaUiPlugin() { - super(); - this.focusListener = this.buildFocusListener(); - if (INSTANCE != null) { - throw new IllegalStateException(); - } - INSTANCE = this; - } - - /** - * We are registered to receive only {@link SWT#FocusIn} events - */ - private Listener buildFocusListener() { - return new Listener() { - public void handleEvent(Event event) { - JptJpaUiPlugin.this.focusIn((Control) event.widget); - } - }; - } - - - // ********** focus handling ********** - - /** - * This method is called whenever a "focus in" event is generated. - * If the control gaining focus is part of one of our composites (typically - * a JPA Details View), we stop listening to Java change events - * (and assume all changes to the Java model are generated by us). - * If the control gaining focus is *not* part of one of our composites, - * we start listening to the Java change events again. - */ - void focusIn(Control control) { - while (control != null) { - if (control.getData(FOCUS_DATA_KEY) == FOCUS_DATA) { - this.focusIn(); - return; - } - control = control.getParent(); - } - this.focusOut(); - } - - /** - * This method is called whenever a Dali UI control that affects Java - * source code gains the UI focus. When this happens we deactivate - * the Dali Java change listener so we ignore any changes to the Java - * source code that probably originated from Dali. This means we will miss - * any changes to the Java source code that is caused by non-UI activity; - * but, we hope, these changes are unrelated to JPA annotations etc. - * @see #focusOut() - */ - private void focusIn() { - JptJpaCorePlugin.setJavaElementChangeListenerIsActive(false); - } - - /** - * This method is called whenever a non-Dali UI control gains the UI focus. - * When this happens we activate the Dali Java change listener so that we - * begin to keep the Dali model synchronized with the Java source code. - * @see #focusIn() - */ - private void focusOut() { - JptJpaCorePlugin.setJavaElementChangeListenerIsActive(true); - } - - /** - * Tag the specified control so that whenever it (or any of its children, - * grandchildren, etc.) has the focus, the Dali model ignores any Java - * change events. This method is to be called when the control is first - * constructed. - */ - public void controlAffectsJavaSource(Control control) { - control.setData(FOCUS_DATA_KEY, FOCUS_DATA); - } - - - // ********** platform ********** - - /** - * Return the JPA platform UI corresponding to the specified JPA platform. - */ - public JpaPlatformUi getJpaPlatformUi(JpaPlatform jpaPlatform) { - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(jpaPlatform.getId()); - } - - public JpaNavigatorProvider getJpaNavigatorProvider(JpaPlatform jpaPlatform) { - JpaPlatformUi platform = this.getJpaPlatformUi(jpaPlatform); - return (platform == null) ? null : platform.getNavigatorProvider(); - } - - - // ********** plug-in implementation ********** - - /** - * Register our SWT listener with the display so we receive notification - * of every "focus in" event. - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - Display.getDefault().addFilter(SWT.FocusIn, this.focusListener); - } - - /** - * Unregister our SWT listener with the display. - */ - @Override - public void stop(BundleContext context) throws Exception { - try { - Display.getDefault().removeFilter(SWT.FocusIn, this.focusListener); - } finally { - super.stop(context); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/MappingResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/MappingResourceUiDefinition.java deleted file mode 100644 index 3f18490732..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/MappingResourceUiDefinition.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui; - -import java.util.Iterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface MappingResourceUiDefinition extends ResourceUiDefinition -{ - /** - * - */ - JpaComposite buildAttributeMappingComposite( - String key, - PropertyValueModel<AttributeMapping> mappingHolder, - Composite parent, WidgetFactory widgetFactory); - - /** - * Return an iterator of attribute mapping ui definitions appropriate for this file type - */ - Iterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>> - attributeMappingUiDefinitions(); - - /** - * Return a default attribute mapping ui definition for the given key or null - */ - DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping> - getDefaultAttributeMappingUiDefinition(String key); - - /** - * - */ - JpaComposite buildTypeMappingComposite( - String key, - PropertyValueModel<TypeMapping> mappingHolder, - Composite parent, WidgetFactory widgetFactory); - - /** - * - */ - Iterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>> - typeMappingUiDefinitions(); - - /** - * Return a default type mapping ui provider or null - */ - DefaultMappingUiDefinition<PersistentType, ? extends TypeMapping> - getDefaultTypeMappingUiDefinition(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java deleted file mode 100644 index c1d4ab6225..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface PersistenceXmlResourceUiDefinition extends ResourceUiDefinition -{ - ListIterator<JpaPageComposite> buildPersistenceUnitComposites( - PropertyValueModel<PersistenceUnit> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java deleted file mode 100644 index 6f7a2e817b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui; - -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -/** - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface ResourceUiDefinition -{ - /** - * Return whether this definition provides UI for resource of the given type - */ - boolean providesUi(JptResourceType resourceType); - - /** - * Return the structure provider association with this mapping file type. - */ - JpaStructureProvider getStructureProvider(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/DefaultMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/DefaultMappingUiDefinition.java deleted file mode 100644 index 1706c2a908..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/DefaultMappingUiDefinition.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.details; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface DefaultMappingUiDefinition<M, T> - extends MappingUiDefinition<M, T> -{ - /** - * Returns a unique string that corresponds to the key of the mapping in the - * core. For a default mapping the method getKey() will return null since - * that is for the specified mapping. This will return the default mapping key, not null - */ - String getDefaultKey(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaComposite.java deleted file mode 100644 index 45a34c1b6c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaComposite.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 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.jpa.ui.details; - -import org.eclipse.swt.widgets.Control; - -/** - * A {@link JpaComposite} defines the common behavior of the JPA related - * widgets. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaComposite { - - /** - * Returns the actual <code>Composite</code>. - * - * @return This composite's actual widget - */ - Control getControl(); - - /** - * Changes the enablement state of the widgets of this pane. - * - * @param enabled <code>true</code> to enable the widgets or <code>false</code> - * to disable them - */ - void enableWidgets(boolean enabled); - - /** - * Notifies this composite it should dispose any resources. - */ - void dispose(); -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaDetailsPage.java deleted file mode 100644 index b24d4d9a3e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaDetailsPage.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.details; - -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.swt.widgets.Control; - -/** - * A details page is used to show the property pane for a given context node. The - * {@link JpaDetailsProvider} is responsible for creating the pane. - * - * @see JpaDetailsProvider - * - * @version 2.0 - * @since 2.0 - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaDetailsPage<T extends JpaStructureNode> -{ - /** - * Returns this details' page's widget. - * - * @return The container of the widgets shown by this details page - */ - Control getControl(); - - /** - * Sets the subject for this details page. - * - * @param subject Either the new subject or <code>null</code> if the subject - * needs to be removed - */ - void setSubject(T subject); - - /** - * Dispose the details page and any resources it holds. - */ - void dispose(); -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaDetailsProvider.java deleted file mode 100644 index a7c11cf787..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaDetailsProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.swt.widgets.Composite; - -/** - * This provider is responsible to create the {@link JpaDetailsPage} - * responsible to show the information for a given content node id. - * - * @see JpaDetailsPage - * - * @version 3.0 - * @since 2.0 - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaDetailsProvider -{ - /** - * Return whether this provider returns a details page for the given structure node - */ - boolean providesDetails(JpaStructureNode structureNode); - - /** - * Creates a new details page based on the given content node id. - * - * @param parent The parent container - * @param contentNodeId The unique identifier used to determine which details - * page to create - * @param widgetFactory The factory used to create various widgets - */ - //TODO Should we pass in JpaUiFactory so these pages can be built using the factory and overriden? - JpaDetailsPage<? extends JpaStructureNode> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaPageComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaPageComposite.java deleted file mode 100644 index 7a28e81d88..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/JpaPageComposite.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.jpa.ui.details; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * A {@link JpaPageComposite} defines the common behavior of the JPA - * related widgets that is shown as a page within an editor. - * <p> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaPageComposite extends JpaComposite { - - /** - * Returns the help ID. This ID will be used if the help button is invoked. - * - * @return Either the help ID of this page or <code>null</code> if no help - * is required - */ - String getHelpID(); - - /** - * The image of the tab showing this page. - * - * @return The page's image - */ - ImageDescriptor getPageImageDescriptor(); - - /** - * The text of the tab showing this page. - * - * @return The page's text - */ - String getPageText(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/MappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/MappingUiDefinition.java deleted file mode 100644 index 01d27f0444..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/MappingUiDefinition.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.details; - -import org.eclipse.swt.graphics.Image; - -/** - * A UI provider is responsible to provide the support for displaying the - * information for a certain mapping type. - * - * T represents the type of the mapping the definition represents - * M represents the type of the object being mapped - * - * @version 2.3 - * @since 2.0 - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface MappingUiDefinition<M, T> -{ - /** - * Returns a unique string that corresponds to the key of the mapping in the - * core (JavaAttributeMappingDefinition and/or OrmAttributeMappingProvider). - * - * @return The key representing the mapping - */ - String getKey(); - - /** - * Returns a human readable text of the mapping type. - * - * @return A display string for the mapping type - */ - String getLabel(); - - /** - * Returns a human readable text of the mapping type to be used in the mapping change link label - */ - String getLinkLabel(); - - /** - * Returns an image that represents the mapping type defined by this provider. - * - * @return An image representing a mapping or <code>null</code> if no image - * is required - */ - Image getImage(); - - /** - * Return whether the mapping type represented by this definition is enabled for the given - * mappable object. This is almost always true. - */ - // TODO bjv remove this; either - // - delegate to whatever controls the list of UI definitions so it can be overridden by EclipseLink - // or - // - delegate to the model definitions (if we think there are more extends that need this...) - boolean isEnabledFor(M mappableObject); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/DefaultJavaAttributeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/DefaultJavaAttributeMappingUiDefinition.java deleted file mode 100644 index 98f781bea6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/DefaultJavaAttributeMappingUiDefinition.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.details.java; - -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface DefaultJavaAttributeMappingUiDefinition<T extends AttributeMapping> - extends JavaAttributeMappingUiDefinition<T>, DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, T> -{ - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/DefaultJavaTypeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/DefaultJavaTypeMappingUiDefinition.java deleted file mode 100644 index 0336b9e18d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/DefaultJavaTypeMappingUiDefinition.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.details.java; - -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface DefaultJavaTypeMappingUiDefinition<T extends TypeMapping> - extends JavaTypeMappingUiDefinition<T>, DefaultMappingUiDefinition<PersistentType, T> -{ - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaAttributeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaAttributeMappingUiDefinition.java deleted file mode 100644 index eca73a692a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaAttributeMappingUiDefinition.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JavaAttributeMappingUiDefinition<T extends AttributeMapping> - extends MappingUiDefinition<ReadOnlyPersistentAttribute, T> -{ - /** - * Creates <code>JpaComposite</code> that corresponds to this mapping type. - * This will be displayed by the <code>PersistentAttributeDetailsPage</code> - * when the mapping key matches the key given by this provider. The - * composites will be stored in a Map with the mapping key as the key. - * - * @param factory The UI factory responsible to create the right composite - * for any mapping type - * @param subjectHolder The holder of the subject being displayed - * @param parent The parent container - * @param widgetFactory The factory used to create the various widgets - * @return The composite displaying the information for a certain mapping - */ - JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaTypeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaTypeMappingUiDefinition.java deleted file mode 100644 index 9583a4809f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaTypeMappingUiDefinition.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JavaTypeMappingUiDefinition<T extends TypeMapping> - extends MappingUiDefinition<PersistentType, T> -{ - /** - * Creates <code>JpaComposite</code> that corresponds to this mapping type. - * This will be displayed by the <code>PersistentTypeDetailsPage</code> when - * the mapping key matches the key given by this provider. The composites - * will be stored in a Map with the mapping key as the key. - * - * @param factory The UI factory responsible to create the right composite - * for any mapping type - * @param subjectHolder The holder of the subject being displayed - * @param parent The parent container - * @param widgetFactory The factory used to create the various widgets - * @return The composite displaying the information for a certain mapping - */ - JpaComposite buildTypeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaUiFactory.java deleted file mode 100644 index f3f86666af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/java/JavaUiFactory.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Use {@link JavaUiFactory} to create any java JPA composites - * <p> - * Provisional API: This interface is part of an interim API that is still under - * development and expected to change significantly before reaching stability. - * It is available at this early stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this API will almost - * certainly be broken (repeatedly) as the API evolves. - * - * - * @version 3.0 - * @since 3.0 - */ -public interface JavaUiFactory -{ - - // **************** java type mapping composites *************************** - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaMappedSuperclass</code>. - * - * @param subjectHolder The holder of the mapped superclass - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaMappedSuperclassComposite( - PropertyValueModel<JavaMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>JavaEntity</code>. - * - * @param subjectHolder The holder of the java entity - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaEntityComposite( - PropertyValueModel<JavaEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaEmbeddable</code>. - * - * @param subjectHolder The holder of the embeddable - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaEmbeddableComposite( - PropertyValueModel<JavaEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - - // **************** orm type mapping composites **************************** - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmMappedSuperclass</code>. - * - * @param subjectHolder The holder of the mapped superclass - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmMappedSuperclassComposite( - PropertyValueModel<OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmEntity</code>. - * - * @param subjectHolder The holder of the orm entity - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmEntityComposite( - PropertyValueModel<OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmEmbeddable</code>. - * - * @param subjectHolder The holder of the embeddable - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmEmbeddableComposite( - PropertyValueModel<OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - - // **************** java attribute mapping composites ********************** - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaIdMapping</code>. - * - * @param subjectHolder The holder of the ID mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaIdMappingComposite( - PropertyValueModel<JavaIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaEmbeddedIdMapping</code>. - * - * @param subjectHolder The holder of the embedded ID mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaEmbeddedIdMappingComposite( - PropertyValueModel<JavaEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaBasicMapping</code>. - * - * @param subjectHolder The holder of the basic mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaBasicMappingComposite( - PropertyValueModel<JavaBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaVersionMapping</code>. - * - * @param subjectHolder The holder of the version mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaVersionMappingComposite( - PropertyValueModel<JavaVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaManyToOneMapping</code>. - * - * @param subjectHolder The holder of the many to one mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaManyToOneMappingComposite( - PropertyValueModel<JavaManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaOneToManyMapping</code>. - * - * @param subjectHolder The holder of the one to many mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaOneToManyMappingComposite( - PropertyValueModel<JavaOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaOneToOneMapping</code>. - * - * @param subjectHolder The holder of the one to one mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaOneToOneMappingComposite( - PropertyValueModel<JavaOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaManyToManyMapping</code>. - * - * @param subjectHolder The holder of the many to many mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaManyToManyMappingComposite( - PropertyValueModel<JavaManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaEmbeddedMapping</code>. - * - * @param subjectHolder The holder of the embedded mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaEmbeddedMappingComposite( - PropertyValueModel<JavaEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit a <code>JavaTransientMapping</code>. - * - * @param subjectHolder The holder of the transient mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createJavaTransientMappingComposite( - PropertyValueModel<JavaTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmAttributeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmAttributeMappingUiDefinition.java deleted file mode 100644 index 2c5861fbe6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmAttributeMappingUiDefinition.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface OrmAttributeMappingUiDefinition<T extends AttributeMapping> - extends MappingUiDefinition<ReadOnlyPersistentAttribute, T> -{ - /** - * Creates <code>JpaComposite</code> that corresponds to this mapping type. - * This will be displayed by the <code>PersistentAttributeDetailsPage</code> - * when the mapping key matches the key given by this provider. The - * composites will be stored in a Map with the mapping key as the key. - * - * @param factory The UI factory responsible to create the right composite - * for any mapping type - * @param subjectHolder The holder of the subject being displayed - * @param parent The parent container - * @param widgetFactory The factory used to create the various widgets - * @return The composite displaying the information for a certain mapping - */ - JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmTypeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmTypeMappingUiDefinition.java deleted file mode 100644 index f9f918bb6b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmTypeMappingUiDefinition.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface OrmTypeMappingUiDefinition<T extends TypeMapping> - extends MappingUiDefinition<PersistentType, T> -{ - /** - * Creates <code>JpaComposite</code> that correponds to this mapping type. - * This will be displayed by the <code>PersistentTypeDetailsPage</code> when - * the mapping key matches the key given by this provider. The composites - * will be stored in a Map with the mapping key as the key. - * - * @param factory The UI factory responsible to create the right composite - * for any mapping type - * @param subjectHolder The holder of the subject being displayed - * @param parent The parent container - * @param widgetFactory The factory used to create the various widgets - * @return The composite displaying the information for a certain mapping - */ - JpaComposite buildTypeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmXmlUiFactory.java deleted file mode 100644 index 6c1eaf975e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/details/orm/OrmXmlUiFactory.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Use {@link OrmXmlUiFactory} to create any ORM JPA composites - * <p> - * Provisional API: This interface is part of an interim API that is still under - * development and expected to change significantly before reaching stability. - * It is available at this early stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this API will almost - * certainly be broken (repeatedly) as the API evolves. - * - * @see org.eclipse.jpt.jpa.ui.internal.BaseJpaUiFactory - * - * @version 2.0 - * @since 1.0 - */ -public interface OrmXmlUiFactory -{ - - // **************** orm type mapping composites **************************** - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmMappedSuperclass</code>. - * - * @param subjectHolder The holder of the mapped superclass - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmMappedSuperclassComposite( - PropertyValueModel<OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmEntity</code>. - * - * @param subjectHolder The holder of the orm entity - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmEntityComposite( - PropertyValueModel<OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmEmbeddable</code>. - * - * @param subjectHolder The holder of the embeddable - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmEmbeddableComposite( - PropertyValueModel<OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - - // **************** orm attribute mapping composites *********************** - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmIdMapping</code>. - * - * @param subjectHolder The holder of the ID mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmIdMappingComposite( - PropertyValueModel<OrmIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmEmbeddedIdMapping</code>. - * - * @param subjectHolder The holder of the embedded ID mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmEmbeddedIdMappingComposite( - PropertyValueModel<OrmEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmBasicMapping</code>. - * - * @param subjectHolder The holder of the basic mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmBasicMappingComposite( - PropertyValueModel<OrmBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmVersionMapping</code>. - * - * @param subjectHolder The holder of the version mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmVersionMappingComposite( - PropertyValueModel<OrmVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmManyToOneMapping</code>. - * - * @param subjectHolder The holder of the many to one mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmManyToOneMappingComposite( - PropertyValueModel<OrmManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmOneToManyMapping</code>. - * - * @param subjectHolder The holder of the one to many mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmOneToManyMappingComposite( - PropertyValueModel<OrmOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmOneToOneMapping</code>. - * - * @param subjectHolder The holder of the one to one mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmOneToOneMappingComposite( - PropertyValueModel<OrmOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmManyToManyMapping</code>. - * - * @param subjectHolder The holder of the many to many mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmManyToManyMappingComposite( - PropertyValueModel<OrmManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmEmbeddedMapping</code>. - * - * @param subjectHolder The holder of the embedded mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmEmbeddedMappingComposite( - PropertyValueModel<OrmEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - - /** - * Creates a new <code>JpaComposite</code> used to edit an <code>OrmTransientMapping</code>. - * - * @param subjectHolder The holder of the transient mapping - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - JpaComposite createOrmTransientMappingComposite( - PropertyValueModel<OrmTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractJpaPlatformUiProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractJpaPlatformUiProvider.java deleted file mode 100644 index 555910e877..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractJpaPlatformUiProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; - -/** - * All the state in the JPA platform ui provider should be "static" (i.e. unchanging once - * it is initialized). - */ -public abstract class AbstractJpaPlatformUiProvider implements JpaPlatformUiProvider -{ - private JpaDetailsProvider[] detailsProviders; - - private ResourceUiDefinition[] resourceUiDefinitions; - - /** - * zero-argument constructor - */ - public AbstractJpaPlatformUiProvider() { - super(); - } - - - // ********** details providers ********** - - public ListIterator<JpaDetailsProvider> detailsProviders() { - return new ArrayListIterator<JpaDetailsProvider>(getDetailsProviders()); - } - - protected synchronized JpaDetailsProvider[] getDetailsProviders() { - if (this.detailsProviders == null) { - this.detailsProviders = this.buildDetailsProviders(); - } - return this.detailsProviders; - } - - protected JpaDetailsProvider[] buildDetailsProviders() { - ArrayList<JpaDetailsProvider> providers = new ArrayList<JpaDetailsProvider>(); - this.addDetailsProvidersTo(providers); - return providers.toArray(new JpaDetailsProvider[providers.size()]); - } - - /** - * Implement this to specify JPA details providers. - */ - protected abstract void addDetailsProvidersTo(List<JpaDetailsProvider> providers); - - - - // ********** structure providers ********** - - public ListIterator<ResourceUiDefinition> resourceUiDefinitions() { - return new ArrayListIterator<ResourceUiDefinition>(getResourceUiDefinitions()); - } - - protected synchronized ResourceUiDefinition[] getResourceUiDefinitions() { - if (this.resourceUiDefinitions == null) { - this.resourceUiDefinitions = this.buildResourceUiDefinitions(); - } - return this.resourceUiDefinitions; - } - - protected ResourceUiDefinition[] buildResourceUiDefinitions() { - ArrayList<ResourceUiDefinition> definitions = new ArrayList<ResourceUiDefinition>(); - this.addResourceUiDefinitionsTo(definitions); - return definitions.toArray(new ResourceUiDefinition[definitions.size()]); - } - - /** - * Implement this to specify JPA mapping file ui definitions. - */ - protected abstract void addResourceUiDefinitionsTo(List<ResourceUiDefinition> definitions); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/EditorPartAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/EditorPartAdapterFactory.java deleted file mode 100644 index f17567c28c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/EditorPartAdapterFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; - -/** - * Factory to build adapters for a editor part: - * - JPA file (if the editor part is a file editor etc.) - * - * See org.eclipse.jpt.jpa.ui plugin.xml. - */ -public class EditorPartAdapterFactory - implements IAdapterFactory -{ - private static final Class<?>[] ADAPTER_LIST = new Class[] { JpaFile.class }; - - public Class<?>[] getAdapterList() { - return ADAPTER_LIST; - } - - public Object getAdapter(Object adaptableObject, @SuppressWarnings("unchecked") Class adapterType) { - if (adaptableObject instanceof IEditorPart) { - return this.getAdapter((IEditorPart) adaptableObject, adapterType); - } - return null; - } - - private Object getAdapter(IEditorPart editorPart, Class<?> adapterType) { - if (adapterType == JpaFile.class) { - return this.getJpaFile(editorPart); - } - return null; - } - - private JpaFile getJpaFile(IEditorPart editorPart) { - IEditorInput editorInput = editorPart.getEditorInput(); - if (editorInput instanceof IFileEditorInput) { - return this.getJpaFile((IFileEditorInput) editorInput); - } - return null; - } - - private JpaFile getJpaFile(IFileEditorInput fileEditorInput) { - return this.getJpaFile(fileEditorInput.getFile()); - } - - private JpaFile getJpaFile(IFile file) { - return JptJpaCorePlugin.getJpaFile(file); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/GenericJpaPlatformUiProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/GenericJpaPlatformUiProvider.java deleted file mode 100644 index 03077a3de2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/GenericJpaPlatformUiProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal; - -import java.util.List; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.java.GenericJavaResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaPersistentAttributeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaPersistentTypeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.EntityMappingsDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentAttributeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentTypeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmXmlUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.PersistenceXmlUiDefinition; - -/** - * All the state in the JPA platform should be "static" (i.e. unchanging once - * it is initialized). - */ -public class GenericJpaPlatformUiProvider extends AbstractJpaPlatformUiProvider -{ - - // singleton - private static final JpaPlatformUiProvider INSTANCE = new GenericJpaPlatformUiProvider(); - - /** - * Return the singleton. - */ - public static JpaPlatformUiProvider instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private GenericJpaPlatformUiProvider() { - super(); - } - - - // ********** details providers ********** - - @Override - protected void addDetailsProvidersTo(List<JpaDetailsProvider> providers) { - providers.add(JavaPersistentTypeDetailsProvider.instance()); - providers.add(JavaPersistentAttributeDetailsProvider.instance()); - providers.add(EntityMappingsDetailsProvider.instance()); - providers.add(OrmPersistentTypeDetailsProvider.instance()); - providers.add(OrmPersistentAttributeDetailsProvider.instance()); - } - - - // ********** resource ui definitions ********** - - @Override - protected void addResourceUiDefinitionsTo(List<ResourceUiDefinition> definitions) { - definitions.add(GenericJavaResourceUiDefinition.instance()); - definitions.add(OrmXmlUiDefinition.instance()); - definitions.add(PersistenceXmlUiDefinition.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ImageRepository.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ImageRepository.java deleted file mode 100644 index b9a5085f86..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ImageRepository.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -@SuppressWarnings("nls") -public final class ImageRepository { - - // ***** overlays ***** - public static Image getErrorOverlayImage(ResourceManager resourceManager) { - return getImage(resourceManager, ERROR_OVERLAY_DESCRIPTOR); - } - private static final ImageDescriptor ERROR_OVERLAY_DESCRIPTOR = buildImageDescriptor("overlays/error.gif"); - - public static Image getWarningOverlayImage(ResourceManager resourceManager) { - return getImage(resourceManager, WARNING_OVERLAY_DESCRIPTOR); - } - private static final ImageDescriptor WARNING_OVERLAY_DESCRIPTOR = buildImageDescriptor("overlays/warning.png"); - - // ***** buttons ***** - public static Image getAddButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, ADD_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor ADD_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/add.png"); - - public static Image getEditButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, EDIT_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor EDIT_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/edit.png"); - - public static Image getDeleteButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, DELETE_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor DELETE_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/delete.png"); - - public static Image getMoveUpButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, MOVE_UP_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor MOVE_UP_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/move-up.png"); - - public static Image getMoveDownButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, MOVE_DOWN_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor MOVE_DOWN_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/move-down.png"); - - public static Image getExpandAllButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, EXPAND_ALL_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor EXPAND_ALL_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/expand-all.png"); - - public static Image getCollapseAllButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, COLLAPSE_ALL_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor COLLAPSE_ALL_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/collapse-all.png"); - - public static Image getRestoreDefaultsButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, RESTORE_DEFAULTS_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor RESTORE_DEFAULTS_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/restore-defaults.png"); - - public static Image getBrowseButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, BROWSE_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor BROWSE_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/browse.png"); - - public static Image getMiniBrowseButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, MINI_BROWSE_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor MINI_BROWSE_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/browse-mini.png"); - - public static Image getSelectAllButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, SELECT_ALL_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor SELECT_ALL_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/select-all.png"); - - public static Image getDeselectAllButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, DESELECT_ALL_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor DESELECT_ALL_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/deselect-all.png"); - - public static Image getAddConnectionButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, ADD_CONNECTION_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor ADD_CONNECTION_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/add-connection.gif"); - - public static Image getReconnectButtonImage(ResourceManager resourceManager) { - return getImage(resourceManager, RECONNECT_BUTTON_DESCRIPTOR); - } - private static final ImageDescriptor RECONNECT_BUTTON_DESCRIPTOR = buildImageDescriptor("buttons/reconnect.png"); - - // ***** objects ***** - public static Image getFileImage(ResourceManager resourceManager) { - return getImage(resourceManager, FILE_DESCRIPTOR); - } - private static final ImageDescriptor FILE_DESCRIPTOR = buildImageDescriptor("objects/file.png"); - - public static Image getFolderImage(ResourceManager resourceManager) { - return getImage(resourceManager, FOLDER_DESCRIPTOR); - } - private static final ImageDescriptor FOLDER_DESCRIPTOR = buildImageDescriptor("objects/folder.png"); - - public static Image getPackageImage(ResourceManager resourceManager) { - return getImage(resourceManager, PACKAGE_DESCRIPTOR); - } - private static final ImageDescriptor PACKAGE_DESCRIPTOR = buildImageDescriptor("objects/package.png"); - - public static Image getTableImage(ResourceManager resourceManager) { - return getImage(resourceManager, TABLE_DESCRIPTOR); - } - private static final ImageDescriptor TABLE_DESCRIPTOR = buildImageDescriptor("objects/table.gif"); - - public static Image getTableObjImage(ResourceManager resourceManager) { - return getImage(resourceManager, TABLE_OBJ_DESCRIPTOR); - } - private static final ImageDescriptor TABLE_OBJ_DESCRIPTOR = buildImageDescriptor("objects/table_obj.gif"); - - public static Image getColumnImage(ResourceManager resourceManager) { - return getImage(resourceManager, COLUMN_DESCRIPTOR); - } - private static final ImageDescriptor COLUMN_DESCRIPTOR = buildImageDescriptor("objects/column.gif"); - - public static Image getKeyColumnImage(ResourceManager resourceManager) { - return getImage(resourceManager, KEY_COLUMN_DESCRIPTOR); - } - private static final ImageDescriptor KEY_COLUMN_DESCRIPTOR = buildImageDescriptor("objects/columnKey.gif"); - - - private static ImageDescriptor buildImageDescriptor(String fileName) { - return AbstractUIPlugin.imageDescriptorFromPlugin(JptJpaUiPlugin.PLUGIN_ID, "images/" + fileName); - } - - - private static Image getImage(ResourceManager resourceManager, ImageDescriptor descriptor) { - return resourceManager.createImage(descriptor); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaHelpContextIds.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaHelpContextIds.java deleted file mode 100644 index 26eb7a6c23..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaHelpContextIds.java +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal; - -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; - -/** - * Help context ids for the Dali JPA UI. - * <p> - * This interface contains constants only; it is not intended to be - * implemented. - * </p> - */ -@SuppressWarnings("nls") -public interface JpaHelpContextIds { - - //ContextID prefix - public static final String PREFIX = JptJpaUiPlugin.PLUGIN_ID + "."; - - //Persistent Type composites - public static final String ENTITY_ACCESS_TYPE = PREFIX + "entity_accessType"; - public static final String ENTITY_ATTRIBUTE_OVERRIDES = PREFIX + "entity_attributeOverrides"; - public static final String ENTITY_ATTRIBUTE_OVERRIDES_COLUMN = PREFIX + "entity_attributeOverridesColumn"; - public static final String ENTITY_CATALOG = PREFIX + "entity_catalog"; - public static final String ENTITY_INHERITANCE_STRATEGY = PREFIX + "entity_inheritanceStrategy"; - public static final String ENTITY_INHERITANCE_DISCRIMINATOR_TYPE = PREFIX + "entity_inheritanceDiscriminatorType"; - public static final String ENTITY_INHERITANCE_DISCRIMINATOR_COLUMN = PREFIX + "entity_inheritanceDiscriminatorColumn"; - public static final String ENTITY_INHERITANCE_DISCRIMINATOR_VALUE = PREFIX + "entity_inheritanceDiscriminatorValue"; - public static final String ENTITY_NAME = PREFIX + "entity_name"; - public static final String ENTITY_ORM_PACKAGE = PREFIX + "orm_package"; - public static final String ENTITY_ORM_SCHEMA = PREFIX + "orm_schema"; - public static final String ENTITY_ORM_CATALOG = PREFIX + "orm_catalog"; - public static final String ENTITY_ORM_ACCESS = PREFIX + "orm_access"; - public static final String ENTITY_ORM_DELIMITED_IDENTIFIERS = PREFIX + "orm_delimited_identifiers"; - public static final String ENTITY_ORM_CASCADE = PREFIX + "orm_cascade"; - public static final String ENTITY_ORM_XML = PREFIX + "orm_xml"; - public static final String ENTITY_SCHEMA = PREFIX + "entity_schema"; - public static final String ENTITY_TABLE = PREFIX + "entity_table"; - public static final String ENTITY_CACHEABLE = PREFIX + "entity_cacheable"; - - //Persistent Attribute composites - public static final String MAPPING_CASCADE_TYPE = PREFIX + "mapping_cascadeType"; - public static final String MAPPING_COLUMN = PREFIX + "mapping_column"; - public static final String MAPPING_COLUMN_INSERTABLE = PREFIX + "mapping_columnInsertable"; - public static final String MAPPING_COLUMN_LENGTH = PREFIX + "mapping_columnLength"; - public static final String MAPPING_COLUMN_NULLABLE = PREFIX + "mapping_columnNullable"; - public static final String MAPPING_COLUMN_PRECISION = PREFIX + "mapping_columnPrecision"; - public static final String MAPPING_COLUMN_SCALE = PREFIX + "mapping_columnScale"; - public static final String MAPPING_COLUMN_TABLE = PREFIX + "mapping_columnTable"; - public static final String MAPPING_COLUMN_UNIQUE = PREFIX + "mapping_columnUnique"; - public static final String MAPPING_COLUMN_UPDATABLE= PREFIX + "mapping_columnUpdatable"; - public static final String MAPPING_EMBEDDED_ATTRIBUTE_OVERRIDES = PREFIX + "mapping_embeddedAttributeOverrides"; - public static final String MAPPING_EMBEDDED_ATTRIBUTE_OVERRIDES_COLUMN = PREFIX + "mapping_embeddedAttributeOverridesColumn"; - public static final String MAPPING_ENUMERATED = PREFIX + "mapping_enumerated"; - public static final String MAPPING_FETCH_TYPE = PREFIX + "mapping_fetchType"; - public static final String MAPPING_GENERATED_VALUE_STRATEGY = PREFIX + "mapping_generatedValueStrategy"; - public static final String MAPPING_GENERATED_VALUE_GENERATOR_NAME = PREFIX + "mapping_generatedValueGeneratorName"; - public static final String MAPPING_JOIN_COLUMN_NAME = PREFIX + "mapping_joinColumnName"; - public static final String MAPPING_JOIN_REFERENCED_COLUMN = PREFIX + "mapping_joinReferencedColumn"; - public static final String MAPPING_JOIN_TABLE_NAME = PREFIX + "mapping_joinTableName"; - public static final String MAPPING_JOIN_TABLE_SCHEMA = PREFIX + "mapping_joinTableSchema"; - public static final String MAPPING_JOIN_TABLE_CATALOG = PREFIX + "mapping_joinTableCatalog"; - public static final String MAPPING_JOIN_TABLE_COLUMNS = PREFIX + "mapping_joinTableJoinColumns"; - public static final String MAPPING_JOIN_TABLE_INVERSE_JOIN_COLUMNS = PREFIX + "mapping_joinTableInverseJoinColumns"; - public static final String MAPPING_LOB = PREFIX + "mapping_lob"; - public static final String MAPPING_MAP_AS = PREFIX + "mapping_mapAs"; - public static final String MAPPING_MAPPED_BY = PREFIX + "mapping_mappedBy"; - public static final String MAPPING_NAMED_NATIVE_QUERIES = "named_native_queries"; - public static final String MAPPING_NAMED_QUERIES = PREFIX + "named_queries"; - public static final String MAPPING_OPTIONAL = PREFIX + "mapping_optional"; - public static final String MAPPING_ORDER_BY = PREFIX + "mapping_orderBy"; - public static final String MAPPING_ORDER_BY_NO_ORDERING = PREFIX + "mapping_orderByNoOrdering"; - public static final String MAPPING_ORDER_BY_PRIMARY_KEY_ORDERING = PREFIX + "mapping_orderByPrimaryKeyOrdering"; - public static final String MAPPING_ORDER_BY_CUSTOM_ORDERING = PREFIX + "mapping_orderByCustomOrdering"; - public static final String MAPPING_ORDER_COLUMN_ORDERING = PREFIX + "mapping_orderColumnOrdering"; - public static final String MAPPING_ORDER_COLUMN_ORDERING_COLUMN = PREFIX + "mapping_orderColumnOrderingColumn"; - public static final String MAPPING_PRIMARY_KEY_GENERATION = PREFIX + "mapping_primaryKeyGeneration"; - public static final String MAPPING_SEQUENCE_GENERATOR = PREFIX + "mapping_sequenceGenerator"; - public static final String MAPPING_SEQUENCE_GENERATOR_NAME = PREFIX + "mapping_sequenceGeneratorName"; - public static final String MAPPING_SEQUENCE_GENERATOR_SEQUENCE = PREFIX + "mapping_sequenceGeneratorSequence"; - public static final String MAPPING_TABLE_GENERATOR = PREFIX + "mapping_tableGenerator"; - public static final String MAPPING_TABLE_GENERATOR_CATALOG = PREFIX + "mapping_tableGeneratorCatalog"; - public static final String MAPPING_TABLE_GENERATOR_NAME = PREFIX + "mapping_tableGeneratorName"; - public static final String MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN = PREFIX + "mapping_tableGeneratorPrimaryKeyColumn"; - public static final String MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN_VALUE = PREFIX + "mapping_tableGeneratorPrimaryKeyColumnValue"; - public static final String MAPPING_TABLE_GENERATOR_SCHEMA = PREFIX + "mapping_tableGeneratorSchema"; - public static final String MAPPING_TABLE_GENERATOR_TABLE= PREFIX + "mapping_tableGeneratorTable"; - public static final String MAPPING_TABLE_GENERATOR_VALUE_COLUMN = PREFIX + "mapping_tableGeneratorValueColumn"; - public static final String MAPPING_TARGET_ENTITY = PREFIX + "mapping_targetEntity"; - public static final String MAPPING_TEMPORAL = PREFIX + "mapping_temporal"; - - //Project properties - public static final String PROPERTIES_JAVA_PERSISTENCE = PREFIX + "properties_javaPersistence"; - public static final String PROPERTIES_JAVA_PERSISTENCE_CONNECTION = PREFIX + "properties_javaPersistenceConnection"; - public static final String PROPERTIES_JAVA_PERSISTENCE_SCHEMA = PREFIX + "properties_javaPersistenceSchema"; - public static final String PROPERTIES_JAVA_PERSISTENCE_METAMODEL = PREFIX + "properties_canonicalMetamodel"; - - //Dialogs, Wizards - public static final String DIALOG_CREATE_ORM = PREFIX + "dialog_createORM"; - public static final String DIALOG_EDIT_INVERSE_JOIN_COLUNN = PREFIX + "dialog_editInverseJoinColumn"; - public static final String DIALOG_GENERATE_ENTITIES = PREFIX + "dialog_generateEntities"; - public static final String DIALOG_GENERATE_ENTITIES_SOURCE = PREFIX + "dialog_generateEntities_source"; - public static final String DIALOG_GENERATE_ENTITIES_PACKAGE = PREFIX + "dialog_generateEntities_package"; - public static final String DIALOG_GENERATE_ENTITIES_TABLES = PREFIX + "dialog_generateEntities_tables"; - public static final String DIALOG_JPA_FACET = PREFIX + "dialog_JPAFacet"; - public static final String DIALOG_JPA_PLATFORM = PREFIX + "dialog_JPAPlatform"; - - //New JPA Project wizard: - public static final String NEW_JPA_PROJECT = PREFIX + "dialog_newJPAProject"; - public static final String NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH = PREFIX + "dialog_addJavaPersistence_classpath"; - public static final String NEW_JPA_PROJECT_CONTENT_PAGE_DATABASE = PREFIX + "dialog_addJavaPersistence_database"; - public static final String NEW_JPA_PROJECT_CONTENT_PAGE_PACKAGING = PREFIX + "dialog_addJavaPersistence_packaging"; - public static final String NEW_JPA_PROJECT_CREATION_PAGE = PREFIX + "dialog_addJavaPersistence"; - public static final String NEW_JPA_PROJECT_JPA_FACET = PREFIX + "dialog_newJPAProjectFacet"; - - //Other - public static final String PERSISTENCE_OUTLINE = PREFIX + "persistenceOutline"; - - //Persistence Xml Editor - public static final String PERSISTENCE_XML_CONNECTION = PREFIX + "persistence_connection"; - public static final String PERSISTENCE_XML_GENERAL = PREFIX + "persistence_general"; - public static final String PERSISTENCE_XML_PROPERTIES = PREFIX + "persistence_properties"; - public static final String PERSISTENCE_XML_SOURCE = PREFIX + "persistence_source"; - - //New JPA Entity wizard - public static final String NEW_JPA_ENTITY_ENTITY_CLASS = PREFIX + "dialog_entityClassPage"; - public static final String NEW_JPA_ENTITY_ENTITY_PROPERTIES = PREFIX + "dialog_entityPropertiesPage"; - - //Generate Entities Wizard - public static final String GENERATE_ENTITIES_WIZARD_ASSOCIATION_CARDINALITY = PREFIX + "dialog_associationCardinalityPage"; - public static final String GENERATE_ENTITIES_WIZARD_ASSOCIATION_TABLES = PREFIX + "dialog_associationTablesPage"; - public static final String GENERATE_ENTITIES_WIZARD_CUSTOMIZE_DEFAULT_ENTITY_GENERATION = PREFIX + "dialog_customizeDefaultEntityGeneration"; - public static final String GENERATE_ENTITIES_WIZARD_CUSTOMIZE_INDIVIDUAL_ENTITIES = PREFIX + "dialog_customizeIndividualEntities"; - public static final String GENERATE_ENTITIES_WIZARD_JOIN_COLUMNS = PREFIX + "dialog_joinColumnsPage"; - public static final String GENERATE_ENTITIES_WIZARD_SELECT_CASCADE = PREFIX + "dialog_selectCascade"; - public static final String GENERATE_ENTITIES_WIZARD_SELECT_TABLES = PREFIX + "dialog_selectTablesPage"; - public static final String GENERATE_ENTITIES_WIZARD_TABLE_ASSOCIATIONS = PREFIX + "dialog_tableAssociationsPage"; - - public static final String MAPPING_COLLECTION_TABLE_NAME = PREFIX + "mapping_collectionTableName"; - public static final String MAPPING_COLLECTION_TABLE_SCHEMA = PREFIX + "mapping_collectionTableSchema"; - public static final String MAPPING_COLLECTION_TABLE_CATALOG = PREFIX + "mapping_collectionTableCatalog"; - - public static final String MAPPING_ELEMENT_COLLECTION_TARGET_CLASS = PREFIX + "mapping_elementCollectionTargetClass"; -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java deleted file mode 100644 index d88d3da7a3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.CompletionContext; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; -import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer; -import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; -import org.eclipse.jface.text.contentassist.CompletionProposal; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; - -/** - * JPA Java code-completion proposal computer - */ -public class JpaJavaCompletionProposalComputer implements IJavaCompletionProposalComputer { - - public JpaJavaCompletionProposalComputer() { - super(); - } - - public void sessionStarted() { - // do nothing - } - - @SuppressWarnings("unchecked") - public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { - return (context instanceof JavaContentAssistInvocationContext) ? - this.computeCompletionProposals((JavaContentAssistInvocationContext) context) - : - Collections.emptyList(); - } - - /** - * We fail silently here because (it seems) <em>expected</em> exceptions occur - * more frequently than intermittent <em>unexpected</em> exceptions that might - * merit investigation (and a logged stacktrace might be the only hint as - * to what happened). - * <p> - * We will get an <em>expected</em> exception (typically a {@link NullPointerException NPE}) - * here if the user:<ol> - * <li>modifies the Java source file in a way that puts it drastically out - * of sync with the Dali context model (e.g. deleting a field or - * annotation) - * <li>immediately invokes Content Assist (typically <code>Ctrl+Space</code>) - * </ol> - * The AST we build here will be based on the just-modified Java source; but, - * since the user moved quickly and we will not have yet received any Java - * change notification (since we only get a Java change notification when - * the user has paused typing for at least 0.5 seconds), the context model - * will still be based on the unmodified Java source. As the new AST is - * passed down through the context model to the resource model all the code - * expects to find the AST in sync with the model. When this is not the - * case (e.g. a field in the resource model is no longer present in the AST - * because the user has deleted it or modified the code in such a way that - * the parser can no longer detect the field) the model will probably choke - * when it cannot find the corresponding AST node. - * <p> - * It seems reasonable, in these situations, to simply return no completion - * proposals. If the user simply waits a moment and tries again, we will be - * able to successfully calculate some proposals. - * <p> - * ~bjv - */ - private List<ICompletionProposal> computeCompletionProposals(JavaContentAssistInvocationContext context) { - try { - return this.computeCompletionProposals_(context); - } catch (Exception ex) { - // JptJpaCorePlugin.log(ex); // don't log "expected" exceptions (?) - return Collections.emptyList(); - } - } - - private List<ICompletionProposal> computeCompletionProposals_(JavaContentAssistInvocationContext context) { - ICompilationUnit cu = context.getCompilationUnit(); - if (cu == null) { - return Collections.emptyList(); - } - - IFile file = this.getCorrespondingResource(cu); - if (file == null) { - return Collections.emptyList(); - } - - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - if (jpaFile == null) { - return Collections.emptyList(); - } - - Collection<JpaStructureNode> rootStructureNodes = CollectionTools.collection(jpaFile.rootStructureNodes()); - if (rootStructureNodes.isEmpty()) { - return Collections.emptyList(); - } - - CompletionContext cc = context.getCoreContext(); - - // the context's "token" is really a sort of "prefix" - it does NOT - // correspond to the "start" and "end" we get below... - char[] prefix = cc.getToken(); - Filter<String> filter = ((prefix == null) ? Filter.Null.<String>instance() : new IgnoreCasePrefixFilter(prefix)); - // the token "start" is the offset of the token's first character - int tokenStart = cc.getTokenStart(); - // the token "end" is the offset of the token's last character (yuk) - int tokenEnd = cc.getTokenEnd(); - if (tokenStart == -1) { // not sure why this happens - see bug 242286 - return Collections.emptyList(); - } - -// System.out.println("prefix: " + ((prefix == null) ? "[null]" : new String(prefix))); -// System.out.println("token start: " + tokenStart); -// System.out.println("token end: " + tokenEnd); -// String source = cu.getSource(); -// String token = source.substring(Math.max(0, tokenStart), Math.min(source.length(), tokenEnd + 1)); -// System.out.println("token: =>" + token + "<="); -// String snippet = source.substring(Math.max(0, tokenStart - 20), Math.min(source.length(), tokenEnd + 21)); -// System.out.println("surrounding snippet: =>" + snippet + "<="); - - // TODO move this parser call into the model... - CompilationUnit astRoot = ASTTools.buildASTRoot(cu); - List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); - for (JpaStructureNode structureNode : rootStructureNodes) { - for (Iterator<String> stream = ((JavaPersistentType) structureNode).javaCompletionProposals(context.getInvocationOffset(), filter, astRoot); stream.hasNext(); ) { - String s = stream.next(); - proposals.add(new CompletionProposal(s, tokenStart, tokenEnd - tokenStart + 1, s.length())); - } - } - return proposals; - } - - private IFile getCorrespondingResource(ICompilationUnit cu) { - try { - return (IFile) cu.getCorrespondingResource(); - } catch (JavaModelException ex) { - JptJpaCorePlugin.log(ex); - return null; - } - } - - @SuppressWarnings("unchecked") - public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { - return Collections.emptyList(); - } - - public String getErrorMessage() { - return null; - } - - public void sessionEnded() { - // do nothing - } - - private static class IgnoreCasePrefixFilter implements Filter<String> { - private final char[] prefix; - IgnoreCasePrefixFilter(char[] prefix) { - super(); - this.prefix = prefix; - } - public boolean accept(String s) { - return StringTools.stringStartsWithIgnoreCase(s.toCharArray(), this.prefix); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaMappingImageHelper.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaMappingImageHelper.java deleted file mode 100644 index 509a13eab8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaMappingImageHelper.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal; - -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.swt.graphics.Image; - -public class JpaMappingImageHelper -{ - - public static Image imageForTypeMapping(String mappingKey) { - return JptJpaUiPlugin.getImage(iconKeyForTypeMapping(mappingKey)); - } - - public static String iconKeyForTypeMapping(String mappingKey) { - if (Tools.valuesAreEqual(mappingKey, MappingKeys.NULL_TYPE_MAPPING_KEY)) { - return JptUiIcons.NULL_TYPE_MAPPING; - } - if (Tools.valuesAreEqual(mappingKey, MappingKeys.ENTITY_TYPE_MAPPING_KEY)) { - return JptUiIcons.ENTITY; - } - if (Tools.valuesAreEqual(mappingKey, MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY)) { - return JptUiIcons.EMBEDDABLE; - } - if (Tools.valuesAreEqual(mappingKey, MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY)) { - return JptUiIcons.MAPPED_SUPERCLASS; - } - return null; - } - - public static Image imageForAttributeMapping(String mappingKey) { - return JptJpaUiPlugin.getImage(iconKeyForAttributeMapping(mappingKey)); - } - - public static String iconKeyForAttributeMapping(String mappingKey) { - if (MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY == mappingKey) { - return JptUiIcons.NULL_ATTRIBUTE_MAPPING; - } - else if (MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.BASIC; - } - else if (MappingKeys.ID_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.ID; - } - else if (MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.VERSION; - } - else if (MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.EMBEDDED_ID; - } - else if (MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.EMBEDDED; - } - else if (MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.ONE_TO_ONE; - } - else if (MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.ONE_TO_MANY; - } - else if (MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.MANY_TO_ONE; - } - else if (MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.MANY_TO_MANY; - } - else if (MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.ELEMENT_COLLECTION; - } - else if (MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptUiIcons.TRANSIENT; - } - //return the JPA_CONTENT icon instead of null, might as well have an icon if one is not defined - return JptUiIcons.JPA_CONTENT; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java deleted file mode 100644 index 5b5a83c909..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal; - -import org.eclipse.draw2d.ImageUtilities; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; - -@SuppressWarnings("nls") -public class JptUiIcons -{ - /** - * Creates and returns a new SWT image that is a grayed out version of the image - * corresponding to the passed in key. Stores this gray image in the JptJpaUiPlugin - * ImageRegistry with -gray appended to the key. - * Clients of this method should not dispose of the image. - * - * @return a new grayed out image - */ - public static Image ghost(String key) { - Image existingImage = JptJpaUiPlugin.instance().getImageRegistry().get(key + "-gray"); - if (existingImage != null) { - return existingImage; - } - - Image grayImage = buildGhostImage(key); - JptJpaUiPlugin.instance().getImageRegistry().put(key + "-gray", grayImage); - return grayImage; - } - - private static Image buildGhostImage(String key) { - Image originalImage = JptJpaUiPlugin.getImage(key); - Color lightGray = new Color(originalImage.getDevice(), 223, 223, 223); - ImageData imageData = ImageUtilities.createShadedImage(originalImage, lightGray); - - Image shadedImage = new Image(originalImage.getDevice(), imageData); - Image grayImage = new Image(originalImage.getDevice(), shadedImage, SWT.IMAGE_GRAY); - - lightGray.dispose(); - shadedImage.dispose(); - return grayImage; - } - - - // **************** General JPA icons ************************************** - - public static final String JPA_CONTENT = "full/obj16/jpa-content"; - - public static final String JPA_FILE = "full/obj16/jpa-file"; - - public static final String JAR_FILE = "full/obj16/jpa-jar-file"; - - public static final String WARNING = "full/obj16/warning"; - - - // **************** Wizard icons ******************************************* - - public static final String JPA_WIZ_BANNER = "full/wizban/new_jpa_prj_wiz"; - - public static final String ENTITY_WIZ_BANNER = "full/wizban/new_entity_wizban"; - - public static final String JPA_FILE_WIZ_BANNER = "full/wizban/new_jpa_file_wizban"; - - - // **************** Persistence icons ************************************** - - public static final String PERSISTENCE = "full/obj16/persistence"; - - public static final String PERSISTENCE_UNIT = "full/obj16/persistence-unit"; - - public static final String MAPPING_FILE_REF = "full/obj16/jpa-file"; - - public static final String CLASS_REF = "full/obj16/null-type-mapping"; - - public static final String JAR_FILE_REF = "full/obj16/jpa-jar-file"; - - - // **************** Orm icons ********************************************** - - public static final String ENTITY_MAPPINGS = "full/obj16/entity-mappings"; - - - // **************** Orm/Java common icons ********************************** - - public static final String ENTITY = "full/obj16/entity"; - - public static final String EMBEDDABLE = "full/obj16/embeddable"; - - public static final String MAPPED_SUPERCLASS = "full/obj16/mapped-superclass"; - - public static final String NULL_TYPE_MAPPING = "full/obj16/null-type-mapping"; - - public static final String ID = "full/obj16/id"; - - public static final String EMBEDDED_ID = "full/obj16/embedded-id"; - - public static final String BASIC = "full/obj16/basic"; - - public static final String VERSION = "full/obj16/version"; - - public static final String MANY_TO_ONE = "full/obj16/many-to-one"; - - public static final String ONE_TO_MANY = "full/obj16/one-to-many"; - - public static final String ONE_TO_ONE = "full/obj16/one-to-one"; - - public static final String MANY_TO_MANY = "full/obj16/many-to-many"; - - public static final String ELEMENT_COLLECTION = "full/obj16/element-collection"; - - public static final String EMBEDDED = "full/obj16/embedded"; - - public static final String TRANSIENT = "full/obj16/transient"; - - public static final String NULL_ATTRIBUTE_MAPPING = "full/obj16/null-attribute-mapping"; -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java deleted file mode 100644 index 19f4ea5bb0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali UI. - * - * @version 3.0 - * @since 1.0 - */ -public class JptUiMessages { - - public static String AccessTypeComposite_access; - public static String AccessTypeComposite_field; - public static String AccessTypeComposite_property; - public static String AddToEarComposite_earMemberShip; - public static String AddToEarComposite_addToEarLabel; - public static String AddToEarComposite_earProjectLabel; - public static String AddToEarComposite_newButtonLabel; - public static String AddPersistentAttributeDialog_attributeLabel; - public static String AddPersistentAttributeDialog_mappingLabel; - public static String AddPersistentAttributeDialog_noMappingKeyError; - public static String AddPersistentAttributeDialog_title; - public static String AddPersistentClassDialog_classDialog_message; - public static String AddPersistentClassDialog_classDialog_title; - public static String AddPersistentClassDialog_classLabel; - public static String AddPersistentClassDialog_classNotFoundWarning; - public static String AddPersistentClassDialog_duplicateClassWarning; - public static String AddPersistentClassDialog_mappingLabel; - public static String AddPersistentClassDialog_noClassError; - public static String AddPersistentClassDialog_noMappingKeyError; - public static String AddPersistentClassDialog_title; - public static String convertToJpa_convertingProject; - public static String convertToJpa_detectingTechnologies; - public static String DatabaseSchemaWizardPage_title; - public static String DatabaseSchemaWizardPage_desc; - public static String DatabaseSchemaWizardPage_schemaSettings; - public static String DatabaseSchemaWizardPage_addConnectionToProject; - public static String DatabaseSchemaWizardPage_connectLink; - public static String DatabaseSchemaWizardPage_schema; - public static String DatabaseSchemaWizardPage_connectionInfo; - public static String DatabaseSchemaWizardPage_schemaInfo; - public static String Error_openingEditor; - public static String General_browse; - public static String General_revert; - public static String General_deselectAll; - public static String General_selectAll; - public static String GenerateDDLWizard_title; - public static String GenerateEntitiesWizard_generateEntities; - public static String GenerateEntitiesWizardPage_chooseEntityTable; - public static String GenerateEntitiesWizardPage_entityNameColumn; - public static String GenerateEntitiesWizardPage_generateEntities; - public static String GenerateEntitiesWizardPage_synchronizeClasses; - public static String GenerateEntitiesWizardPage_tableColumn; - public static String GenerateEntitiesWizardPage_tables; - public static String GenericPlatformUiDialog_notSupportedMessageText; - public static String GenericPlatformUiDialog_notSupportedMessageTitle; - public static String JpaContent_label; - public static String JpaDetailsView_viewNotAvailable; - public static String JpaFacetWizardPage_addDriverLibraryLabel; - public static String JpaFacetWizardPage_connectionLabel; - public static String JpaFacetWizardPage_connectionLink; - public static String JpaFacetWizardPage_connectLink; - public static String JpaFacetWizardPage_connectedText; - public static String JpaFacetWizardPage_createOrmXmlButton; - public static String JpaFacetWizardPage_defaultCatalogLabel; - public static String JpaFacetWizardPage_defaultSchemaLabel; - public static String JpaFacetWizardPage_description; - public static String JpaFacetWizardPage_discoverClassesButton; - public static String JpaFacetWizardPage_driverLibraryLabel; - public static String JpaFacetWizardPage_facetsPageLink; - public static String JpaFacetWizardPage_metamodelSourceFolderLink; - public static String JpaFacetWizardPage_jpaImplementationLabel; - public static String JpaFacetWizardPage_jpaPrefsLink; - public static String JpaFacetWizardPage_listClassesButton; - public static String JpaFacetWizardPage_metamodelLabel; - public static String JpaFacetWizardPage_none; - public static String JpaFacetWizardPage_overrideDefaultCatalogLabel; - public static String JpaFacetWizardPage_overrideDefaultSchemaLabel; - public static String JpaFacetWizardPage_persistentClassManagementLabel; - public static String JpaFacetWizardPage_platformLabel; - public static String JpaFacetWizardPage_specifyLibLabel; - public static String JpaFacetWizardPage_title; - public static String JpaFacetWizardPage_userLibsLink; - public static String JpaFacetWizardPage_userServerLibLabel; - public static String JpaLibraryProviderInstallPanel_includeLibraries; - public static String JpaMakePersistentWizardPage_title; - public static String JpaMakePersistentWizardPage_message; - public static String JpaMakePersistentWizardPage_annotateInJavaRadioButton; - public static String JpaMakePersistentWizardPage_mappingFileRadioButton; - public static String JpaMakePersistentWizardPage_mappingFileLink; - public static String JpaMakePersistentWizardPage_mappingFileBrowseButton; - public static String JpaMakePersistentWizardPage_typeTableColumn; - public static String JpaMakePersistentWizardPage_mappingTableColumn; - public static String JpaMakePersistentWizardPage_listInPersistenceXmlCheckBox; - public static String JpaMakePersistentWizardPage_selectedTypesPersistentError; - public static String JpaMakePersistentWizardPage_mappingFileDoesNotExistError; - public static String JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError; - public static String JpaStructureView_linkWithEditorDesc; - public static String JpaStructureView_linkWithEditorText; - public static String JpaStructureView_linkWithEditorTooltip; - public static String JpaStructureView_structureNotAvailable; - public static String JpaStructureView_numItemsSelected; - public static String MappingFileWizard_title; - public static String MappingFileWizardPage_newFile_title; - public static String MappingFileWizardPage_newFile_desc; - public static String MappingFileWizardPage_options_title; - public static String MappingFileWizardPage_options_desc; - public static String MappingFileWizardPage_projectLabel; - public static String MappingFileWizardPage_sourceFolderLabel; - public static String MappingFileWizardPage_filePathLabel; - public static String MappingFileWizardPage_accessLabel; - public static String MappingFileWizardPage_addToPersistenceUnitButton; - public static String MappingFileWizardPage_persistenceUnitLabel; - public static String MappingFileWizardPage_incorrectSourceFolderError; - public static String MappingFileWizardPage_accessLabel_sourceFolderDialogTitle; - public static String MappingFileWizardPage_accessLabel_sourceFolderDialogDesc; - public static String JpaProjectWizard_title; - public static String NewJpaProjectWizard_firstPage_description; - public static String NewJpaProjectWizard_firstPage_title; - public static String OrmItemLabelProviderFactory_entityMappingsLabel; - public static String OverwriteConfirmerDialog_text; - public static String OverwriteConfirmerDialog_title; - public static String PersistenceItemLabelProviderFactory_persistenceLabel; - public static String EntitiesGenerator_jobName; - public static String JpaPreferencesPage_Description; - public static String JpaProblemSeveritiesPage_Description; - public static String JpaProblemSeveritiesPage_Error; - public static String JpaProblemSeveritiesPage_Ignore; - public static String JpaProblemSeveritiesPage_Info; - public static String JpaProblemSeveritiesPage_Warning; - public static String SelectJpaOrmMappingFileDialog_newButton; - - - private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiMessages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiMessages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java deleted file mode 100644 index a9bfccf5a0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal; - -import org.eclipse.osgi.util.NLS; - -public class JptUiValidationPreferenceMessages { - - public static String PROJECT_LEVEL_CATEGORY; - public static String NO_JPA_PROJECT; - public static String PROJECT_NO_CONNECTION; - public static String PROJECT_INVALID_CONNECTION; - public static String PROJECT_INACTIVE_CONNECTION; - public static String PROJECT_NO_PERSISTENCE_XML; - - public static String XML_VERSION_NOT_LATEST; - - public static String PROJECT_MULTIPLE_PERSISTENCE_XML; - public static String PERSISTENCE_NO_PERSISTENCE_UNIT; - public static String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS; - public static String PERSISTENCE_XML_INVALID_CONTENT; - - public static String PERSISTENCE_UNIT_LEVEL_CATEGORY; - public static String PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE; - public static String PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT; - public static String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE; - public static String PERSISTENCE_UNIT_INVALID_MAPPING_FILE; - public static String PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE; - public static String PERSISTENCE_UNIT_UNSPECIFIED_CLASS; - public static String PERSISTENCE_UNIT_NONEXISTENT_CLASS; - public static String PERSISTENCE_UNIT_INVALID_CLASS; - public static String PERSISTENCE_UNIT_DUPLICATE_CLASS; - public static String PERSISTENCE_UNIT_REDUNDANT_CLASS; - public static String PERSISTENCE_UNIT_DUPLICATE_JAR_FILE; - public static String PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE; - public static String PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING; - public static String PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE; - public static String MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA; - public static String PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT; - public static String PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT; - public static String PERSISTENT_TYPE_UNSPECIFIED_CLASS; - public static String PERSISTENT_TYPE_UNRESOLVED_CLASS; - - public static String TYPE_LEVEL_CATEGORY; - public static String ENTITY_NO_PK; - public static String ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE; - public static String ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE; - public static String ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED; - public static String ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED; - public static String ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED; - public static String ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED; - public static String TYPE_MAPPING_FINAL_CLASS; - public static String TYPE_MAPPING_MEMBER_CLASS; - public static String TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR; - public static String TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR; - public static String PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME; - public static String PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME; - public static String PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED; - public static String PERSISTENT_ATTRIBUTE_INVALID_MAPPING; - public static String PERSISTENT_ATTRIBUTE_FINAL_FIELD; - public static String PERSISTENT_ATTRIBUTE_FINAL_GETTER; - public static String PERSISTENT_ATTRIBUTE_PUBLIC_FIELD; - - public static String ATTRIBUTE_LEVEL_CATEGORY; - public static String MAPPING_UNRESOLVED_MAPPED_BY; - public static String MAPPING_INVALID_MAPPED_BY; - public static String MAPPING_MAPPED_BY_WITH_JOIN_TABLE; - public static String MAPPING_MAPPED_BY_ON_BOTH_SIDES; - public static String TARGET_ENTITY_NOT_DEFINED; - public static String TARGET_ENTITY_IS_NOT_AN_ENTITY; - public static String MAPS_ID_VALUE_NOT_SPECIFIED; - public static String MAPS_ID_VALUE_NOT_RESOLVED; - public static String MAPS_ID_VALUE_INVALID; - public static String ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED; - public static String ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED; - public static String ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE; - public static String ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED; - - public static String DATABASE_CATEGORY; - public static String TABLE_CATEGORY; - public static String COLUMN_CATEGORY; - public static String OVERRIDES_CATEGORY; - public static String IMPLIED_ATTRIBUTE_LEVEL_CATEGORY; - - public static String TABLE_UNRESOLVED_CATALOG; - public static String TABLE_UNRESOLVED_SCHEMA; - public static String TABLE_UNRESOLVED_NAME; - public static String SECONDARY_TABLE_UNRESOLVED_CATALOG; - public static String SECONDARY_TABLE_UNRESOLVED_SCHEMA; - public static String SECONDARY_TABLE_UNRESOLVED_NAME; - public static String JOIN_TABLE_UNRESOLVED_CATALOG; - public static String JOIN_TABLE_UNRESOLVED_SCHEMA; - public static String JOIN_TABLE_UNRESOLVED_NAME; - public static String COLUMN_TABLE_NOT_VALID; - public static String COLUMN_UNRESOLVED_TABLE; - public static String COLUMN_UNRESOLVED_NAME; - public static String JOIN_COLUMN_TABLE_NOT_VALID; - public static String JOIN_COLUMN_UNRESOLVED_NAME; - public static String JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME; - public static String PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String MAP_KEY_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - - public static String COLLECTION_TABLE_UNRESOLVED_CATALOG; - public static String COLLECTION_TABLE_UNRESOLVED_SCHEMA; - public static String COLLECTION_TABLE_UNRESOLVED_NAME; - public static String ORDER_COLUMN_UNRESOLVED_NAME; - - public static String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG; - public static String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA; - public static String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME; - public static String ATTRIBUTE_OVERRIDE_INVALID_NAME; - public static String ASSOCIATION_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_ATTRIBUTE_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME; - public static String VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE; - public static String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY; - public static String VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED; - public static String VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_CATALOG; - public static String VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_SCHEMA; - public static String VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_ORDER_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED; - public static String VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE; - public static String VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED; - public static String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS; - public static String VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS; - public static String VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS; - - public static String INHERITANCE_CATEGORY; - public static String DISCRIMINATOR_COLUMN_UNRESOLVED_NAME; - public static String ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM; - public static String ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM; - - public static String QUERIES_GENERATORS_CATEGORY; - public static String GENERATOR_DUPLICATE_NAME; - public static String ID_MAPPING_UNRESOLVED_GENERATOR_NAME; - public static String GENERATED_VALUE_UNRESOLVED_GENERATOR; - public static String QUERY_DUPLICATE_NAME; - - private static final String BUNDLE_NAME = "jpt_ui_validation_preferences"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiValidationPreferenceMessages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiValidationPreferenceMessages() { - throw new UnsupportedOperationException(); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateDDLAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateDDLAction.java deleted file mode 100644 index f6aca3be2b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateDDLAction.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.actions; - -import org.eclipse.jpt.jpa.core.JpaProject; - -/** - * GenerateDDLAction - */ -public class GenerateDDLAction extends ProjectAction { - - public GenerateDDLAction() { - super(); - } - - @Override - protected void execute(JpaProject project) { - this.getJpaPlatformUi(project).generateDDL(project, this.getCurrentSelection()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateEntitiesAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateEntitiesAction.java deleted file mode 100644 index 383633831a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/GenerateEntitiesAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2007, 2009 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.jpa.ui.internal.actions; - -import org.eclipse.jpt.jpa.core.JpaProject; - -/** - * GenerateEntitiesAction - */ -public class GenerateEntitiesAction extends ProjectAction { - public GenerateEntitiesAction() { - super(); - } - - @Override - protected void execute(JpaProject project) { - this.getJpaPlatformUi(project).generateEntities(project, this.getCurrentSelection()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/MakePersistentAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/MakePersistentAction.java deleted file mode 100644 index 4fcf0b4caf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/MakePersistentAction.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* -* 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.jpa.ui.internal.actions; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.wizards.JpaMakePersistentWizard; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - - -public class MakePersistentAction implements IObjectActionDelegate { - - - private Map<IProject, List<IType>> selectedTypes; - - public MakePersistentAction() { - super(); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // do nothing - } - - public void selectionChanged(IAction action, ISelection selection) { - // Action is contributed for IType, ICompilationUnit, IPackageFragment, and IPackageFragmentRoot that is a source folder - this.selectedTypes = this.buildSelectedTypes((StructuredSelection) selection); - } - - protected Map<IProject, List<IType>> buildSelectedTypes(StructuredSelection structuredSelection) { - Map<IProject, List<IType>> types = new HashMap<IProject, List<IType>>(); - - for (Object selection : structuredSelection.toList()) { - switch (((IJavaElement) selection).getElementType()) { - case IJavaElement.TYPE : - addSelectedType((IType) selection, types); - break; - case IJavaElement.COMPILATION_UNIT : - addSelectedType((ICompilationUnit) selection, types); - break; - case IJavaElement.PACKAGE_FRAGMENT : - addSelectedType((IPackageFragment) selection, types); - break; - case IJavaElement.PACKAGE_FRAGMENT_ROOT : - addSelectedType((IPackageFragmentRoot) selection, types); - break; - default : - break; - } - } - return types; - } - - private void addSelectedType(IPackageFragmentRoot packageFragmentRoot, Map<IProject, List<IType>> types) { - for (IJavaElement pkgFragment : getPackageFragments(packageFragmentRoot)) { - addSelectedType((IPackageFragment) pkgFragment, types); - } - } - - private void addSelectedType(IPackageFragment packageFragment, Map<IProject, List<IType>> types) { - for (ICompilationUnit compUnit : getCompilationUnits(packageFragment)) { - addSelectedType(compUnit, types); - } - } - - private void addSelectedType(ICompilationUnit compilationUnit, Map<IProject, List<IType>> types) { - IType primaryType = this.getPrimaryType(compilationUnit); - if (primaryType != null) { - this.addSelectedType(primaryType, types); - } - } - - private void addSelectedType(IType primaryType, Map<IProject, List<IType>> typesMap) { - IProject project = primaryType.getJavaProject().getProject(); - List<IType> types = typesMap.get(project); - if (types == null) { - types = new ArrayList<IType>(); - typesMap.put(project, types); - } - if (!types.contains(primaryType)) { - types.add(primaryType); - } - } - - private ICompilationUnit[] getCompilationUnits(IPackageFragment packageFragment) { - try { - return packageFragment.getCompilationUnits(); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - return new ICompilationUnit[0]; - } - - private IJavaElement[] getPackageFragments(IPackageFragmentRoot packageFragmentRoot) { - try { - return packageFragmentRoot.getChildren(); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - return new IJavaElement[0]; - } - - private IType getPrimaryType(ICompilationUnit compilationUnit) { - return compilationUnit.findPrimaryType(); - } - - public void run(IAction action) { - for (List<IType> types : this.selectedTypes.values()) { - //open the wizard once for each selected project - JpaMakePersistentWizard wizard = new JpaMakePersistentWizard(types); - WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard); - dialog.create(); - dialog.open(); - } - } - - private Shell getCurrentShell() { - return Display.getCurrent().getActiveShell(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/OpenJpaResourceAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/OpenJpaResourceAction.java deleted file mode 100644 index b9c222d0c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/OpenJpaResourceAction.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.BaseSelectionListenerAction; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; - -public class OpenJpaResourceAction extends BaseSelectionListenerAction -{ - private JpaContextNode selectedNode; - - - public OpenJpaResourceAction() { - super("Open"); //$NON-NLS-1$ - } - - - @Override - public boolean updateSelection(IStructuredSelection s) { - selectedNode = null; - - if (! super.updateSelection(s)) { - return false; - } - - if (s.size() != 1) { - return false; - } - - if (s.getFirstElement() instanceof JpaRootContextNode) { - return false; - } - - selectedNode = (JpaContextNode) s.getFirstElement(); - - return true; - } - - @Override - public void run() { - if (! isEnabled()) { - return; - } - - IResource resource = selectedNode.getResource(); - - if (resource != null && resource.exists() && resource.getType() == IResource.FILE) { - openEditor((IFile) resource); - - - if (selectedNode instanceof JpaStructureNode) { - JpaSelectionManager selectionManager = - SelectionManagerFactory.getSelectionManager(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - selectionManager.select(new DefaultJpaSelection((JpaStructureNode) selectedNode), null); - } - } - } - - protected void openEditor(IFile file) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IContentType contentType = IDE.getContentType(file); - IEditorDescriptor editorDescriptor = registry.getDefaultEditor(file.getName(), contentType); - if (editorDescriptor == null) { - return; // no editor associated... - } - - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - try { - page.openEditor(new FileEditorInput(file), editorDescriptor.getId()); - } - catch (Exception e) { - MessageDialog.openError(page.getWorkbenchWindow().getShell(), JptUiMessages.Error_openingEditor, e.getMessage()); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/ProjectAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/ProjectAction.java deleted file mode 100644 index a91b6381f2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/ProjectAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.actions; - -import java.util.Iterator; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Override any of the #execute() methods. - */ -public abstract class ProjectAction implements IObjectActionDelegate { - - private ISelection currentSelection; - - - public ProjectAction() { - super(); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // do nothing - } - - public void selectionChanged(IAction action, ISelection selection) { - this.currentSelection = selection; - } - - protected IStructuredSelection getCurrentSelection() { - if (this.currentSelection instanceof IStructuredSelection) { - return (IStructuredSelection) this.currentSelection; - } - return null; - } - - public void run(IAction action) { - if (this.currentSelection instanceof IStructuredSelection) { - for (Iterator stream = ((IStructuredSelection) this.currentSelection).iterator(); stream.hasNext(); ) { - this.execute(stream.next()); - } - } - } - - protected void execute(Object selection) { - IProject project = this.projectFromSelection(selection); - if (project != null) { - this.execute(project); - } - } - - protected IProject projectFromSelection(Object selection) { - if (selection instanceof IProject) { - return (IProject) selection; - } - if (selection instanceof IJavaProject) { - return ((IJavaProject) selection).getProject(); - } - return null; - } - - protected JpaPlatformUi getJpaPlatformUi(JpaProject project) { - String coreJpaPlatformId = project.getJpaPlatform().getId(); - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(coreJpaPlatformId); - } - - protected void execute(IProject project) { - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project); - if (jpaProject == null) { - return; - } - this.execute(jpaProject); - } - - protected void execute(JpaProject project) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/SynchronizeClassesAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/SynchronizeClassesAction.java deleted file mode 100644 index 9f16d7a440..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/actions/SynchronizeClassesAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.jpa.ui.internal.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.core.internal.synch.SynchronizeClassesJob; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -public class SynchronizeClassesAction - implements IObjectActionDelegate -{ - private IFile file; - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // no-op for now - } - - public void run(IAction action) { - SynchronizeClassesJob job = new SynchronizeClassesJob(file); - job.schedule(); - } - - public void selectionChanged(IAction action, ISelection selection) { - // Action is contributed for IFile's named "persistence.xml" and - // for PeristenceXml objects. - // There is always only one element in actual selection. - Object selectedObject = ((StructuredSelection) selection).getFirstElement(); - - if (selectedObject instanceof IFile) { - file = (IFile) selectedObject; - } - else if (selectedObject instanceof PersistenceXml) { - file = (IFile) ((PersistenceXml) selectedObject).getResource(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentAttributeToXmlAndMapHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentAttributeToXmlAndMapHandler.java deleted file mode 100644 index 9507ee9bad..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentAttributeToXmlAndMapHandler.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.commands; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.internal.dialogs.AddPersistentAttributeToXmlAndMapDialog; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; - -public class AddPersistentAttributeToXmlAndMapHandler extends AbstractHandler -{ - @SuppressWarnings("unchecked") - public Object execute(ExecutionEvent executionEvent) throws ExecutionException { - final IWorkbenchWindow window = - HandlerUtil.getActiveWorkbenchWindowChecked(executionEvent); - - final List<OrmReadOnlyPersistentAttribute> newAttributes = new ArrayList<OrmReadOnlyPersistentAttribute>(); - - IStructuredSelection selection - = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(executionEvent); - - - // only applies for multiply selected OrmReadOnlyPersistentAttribute objects in a tree - for (OrmReadOnlyPersistentAttribute attribute : (Iterable<OrmReadOnlyPersistentAttribute>) CollectionTools.iterable(selection.iterator())) { - OrmPersistentType type = attribute.getOwningPersistentType(); - String attributeName = attribute.getName(); - - AddPersistentAttributeToXmlAndMapDialog dialog = new AddPersistentAttributeToXmlAndMapDialog(window.getShell(), attribute); - dialog.create(); - dialog.setBlockOnOpen(true); - dialog.open(); - - OrmReadOnlyPersistentAttribute newAttribute = type.getAttributeNamed(attributeName); - if (newAttribute != null) { - newAttributes.add(newAttribute); - } - } - - if (newAttributes.size() == 1) { - window.getShell().getDisplay().asyncExec( - new Runnable() { - public void run() { - JpaSelectionManager selectionManager = SelectionManagerFactory.getSelectionManager(window); - selectionManager.select(new DefaultJpaSelection(newAttributes.get(0)), null); - } - }); - } - - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentAttributeToXmlHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentAttributeToXmlHandler.java deleted file mode 100644 index 7880e2371d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentAttributeToXmlHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.commands; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; - -public class AddPersistentAttributeToXmlHandler extends AbstractHandler -{ - @SuppressWarnings("unchecked") - public Object execute(ExecutionEvent executionEvent) throws ExecutionException { - final IWorkbenchWindow window = - HandlerUtil.getActiveWorkbenchWindowChecked(executionEvent); - - final List<OrmReadOnlyPersistentAttribute> newAttributes = new ArrayList<OrmReadOnlyPersistentAttribute>(); - - IStructuredSelection selection = - (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(executionEvent); - - // only applies for multiply selected OrmReadOnlyPersistentAttribute objects in a tree - for (OrmReadOnlyPersistentAttribute attribute : (Iterable<OrmReadOnlyPersistentAttribute>) CollectionTools.iterable(selection.iterator())) { - newAttributes.add(attribute.convertToSpecified()); - } - - if (newAttributes.size() == 1) { - window.getShell().getDisplay().asyncExec( - new Runnable() { - public void run() { - JpaSelectionManager selectionManager = SelectionManagerFactory.getSelectionManager(window); - selectionManager.select(new DefaultJpaSelection(newAttributes.get(0)), null); - } - }); - } - - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentClassHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentClassHandler.java deleted file mode 100644 index 1068d7fd75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AddPersistentClassHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.ui.internal.dialogs.AddPersistentClassDialog; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; - -public class AddPersistentClassHandler extends AbstractHandler -{ - public Object execute(ExecutionEvent executionEvent) throws ExecutionException { - final IWorkbenchWindow window = - HandlerUtil.getActiveWorkbenchWindowChecked(executionEvent); - - IStructuredSelection selection - = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(executionEvent); - - // only applies for a singly selected EntityMappings object in a tree - EntityMappings entityMappings = - (EntityMappings) selection.getFirstElement(); - - AddPersistentClassDialog dialog = - new AddPersistentClassDialog(window.getShell(), entityMappings); - dialog.create(); - dialog.setBlockOnOpen(true); - final OrmPersistentType type = dialog.openAndReturnType(); - - if (type != null) { - window.getShell().getDisplay().asyncExec( - new Runnable() { - public void run() { - JpaSelectionManager selectionManager = SelectionManagerFactory.getSelectionManager(window); - selectionManager.select(new DefaultJpaSelection(type), null); - } - }); - } - - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/ConvertJavaProjectToJpaCommandHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/ConvertJavaProjectToJpaCommandHandler.java deleted file mode 100644 index 66f9eaaefb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/ConvertJavaProjectToJpaCommandHandler.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.commands; - -import static org.eclipse.wst.common.project.facet.core.util.internal.FileUtil.*; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.internal.FacetedProjectNature; -import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard; - -public class ConvertJavaProjectToJpaCommandHandler - extends AbstractHandler { - - public Object execute(ExecutionEvent event) - throws ExecutionException { - - IProject project = null; - ISelection currentSelection = HandlerUtil.getCurrentSelection(event); - - if (currentSelection instanceof IStructuredSelection) { - Object element = ((IStructuredSelection) currentSelection).getFirstElement(); - project = (IProject) Platform.getAdapterManager().getAdapter(element, IProject.class); - } - - if (project == null) { - return null; - } - - IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); - - if (activeWorkbenchWindow != null) { - Shell shell = activeWorkbenchWindow.getShell(); - - ConvertJavaProjectToJpaRunnable.runInProgressDialog(shell, project); - } - - return null; - } - - - private static class ConvertJavaProjectToJpaRunnable - implements IRunnableWithProgress { - - private final IProject project; - private IFacetedProjectWorkingCopy fprojwc; - - public static void runInProgressDialog(Shell shell, IProject project) { - final ConvertJavaProjectToJpaRunnable runnable - = new ConvertJavaProjectToJpaRunnable(project); - - try { - new ProgressMonitorDialog(shell).run(true, true, runnable); - - ModifyFacetedProjectWizard wizard - = new ModifyFacetedProjectWizard(runnable.getFacetedProjectWorkingCopy()); - WizardDialog dialog = new WizardDialog(shell, wizard); - - if (dialog.open() == Dialog.CANCEL) { - throw new InterruptedException(); - } - } - catch (InvocationTargetException e) { - JptJpaUiPlugin.log(e); - } - catch(InterruptedException e) { - removeFacetNature(project); - } - } - - - public static void removeFacetNature(IProject project) { - try { - IProjectDescription description = project.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = ArrayTools.remove(prevNatures, FacetedProjectNature.NATURE_ID); - description.setNatureIds( newNatures ); - - validateEdit( project.getFile( FILE_DOT_PROJECT ) ); - - project.setDescription(description, null); - } - catch (CoreException ce) { - JptJpaUiPlugin.log(ce); - } - } - - - public ConvertJavaProjectToJpaRunnable(IProject project) { - this.project = project; - } - - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - - monitor.beginTask(JptUiMessages.convertToJpa_convertingProject, 1000); - - try { - IProgressMonitor createProgressMonitor = new SubProgressMonitor(monitor, 100); - IFacetedProject fproj = ProjectFacetsManager.create(this.project, true, createProgressMonitor); - - if (monitor.isCanceled()) { - throw new InterruptedException(); - } - - monitor.setTaskName(JptUiMessages.convertToJpa_detectingTechnologies); - - IProgressMonitor detectProgressMonitor = new SubProgressMonitor(monitor, 800); - this.fprojwc = fproj.createWorkingCopy(); - this.fprojwc.detect(detectProgressMonitor); - - if (! this.fprojwc.hasProjectFacet(JpaFacet.FACET)) { - this.fprojwc.addProjectFacet(JpaFacet.FACET.getDefaultVersion()); - } - } - catch(CoreException e) { - throw new InvocationTargetException(e); - } - finally { - monitor.done(); - } - } - - protected IFacetedProjectWorkingCopy getFacetedProjectWorkingCopy() { - return this.fprojwc; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java deleted file mode 100644 index 8a2c034563..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.commands; - -import java.util.Map; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.ui.ISources; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.commands.IElementUpdater; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.menus.UIElement; -import org.eclipse.ui.services.IEvaluationService; - -/** - * This handler is responsible to change the mapping type of the selected - * <code>PersistentAttribute</code>. - * <p> - * This handler is defined in the JPT plugin.xml. It will be invoked by the - * mapping action dynamically created by the <code>PersistentAttributeMapAsContribution</code>. - * - * @see PersistentAttribute - * @see PersistentAttributeMapAsContribution - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class PersistentAttributeMapAsHandler extends AbstractHandler - implements IElementUpdater -{ - /** - * The unique identifier of the Map As command used for <code>PersistentAttribute</code> - * defined in the <code>JptJpaUiPlugin</code> plugin.xml. - */ - public static final String COMMAND_ID = "org.eclipse.jpt.jpa.ui.persistentAttributeMapAs"; - - /** - * The unique identifier of the Map As command parameter used for <code>PersistentAttribute</code> - * defined in the <code>JptJpaUiPlugin</code> plugin.xml. - */ - public static final String SPECIFIED_MAPPING_COMMAND_PARAMETER_ID = "specifiedPersistentAttributeMappingKey"; - - public static final String DEFAULT_MAPPING_COMMAND_PARAMETER_ID = "defaultPersistentAttributeMappingKey"; - - /** - * Creates a new <code>PersistentAttributeMapAsHandler</code>. - */ - public PersistentAttributeMapAsHandler() { - super(); - } - - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Retrieve the selection from the ExecutionEvent - IStructuredSelection selection = (IStructuredSelection) - HandlerUtil.getCurrentSelectionChecked(event); - - // Retrieve the value of the unique parameter passed to the command - String mappingKey = event.getParameter(SPECIFIED_MAPPING_COMMAND_PARAMETER_ID); - - // Change the mapping key for all the selected items - for (Object item : selection.toArray()) { - PersistentAttribute attribute = (PersistentAttribute) item; - attribute.setMappingKey(mappingKey); - } - - return null; - } - - public void updateElement(UIElement element, @SuppressWarnings("unchecked") Map parameters) { - // Retrieve the selection for the UIElement - - // Due to Bug 226746, we have to use API workaround to retrieve current - // selection - IEvaluationService es - = (IEvaluationService) element.getServiceLocator().getService(IEvaluationService.class); - IViewPart part = - (IViewPart) es.getCurrentState().getVariable(ISources.ACTIVE_PART_NAME); - IStructuredSelection selection - = (IStructuredSelection) part.getSite().getSelectionProvider().getSelection(); - - element.setChecked(selectedElementsMappingKeysMatch(selection, parameters)); - } - - //Check all the selected persistent attribute and verify that they have the same mapping type. - //They must all be either default mappings or specified mappings as well. - protected boolean selectedElementsMappingKeysMatch(IStructuredSelection selection, @SuppressWarnings("unchecked") Map parameters) { - String handlerSpecifiedMappingKey = (String) parameters.get(SPECIFIED_MAPPING_COMMAND_PARAMETER_ID); - String handlerDefaultMappingKey = (String) parameters.get(DEFAULT_MAPPING_COMMAND_PARAMETER_ID); - - String commonDefaultKey = null; - String commonSpecifiedKey = null; - for (Object obj : selection.toArray()) { - if (! (obj instanceof PersistentAttribute)) { - //oddly enough, you have to check instanceof here, seems like a bug in the framework - return false; - } - - PersistentAttribute persistentAttribute = (PersistentAttribute) obj; - if (persistentAttribute.getMapping().isDefault()) { - if (commonSpecifiedKey != null) { - return false; - } - if (commonDefaultKey == null) { - commonDefaultKey = persistentAttribute.getMappingKey(); - } - else if (!commonDefaultKey.equals(persistentAttribute.getMappingKey())) { - return false; - } - } - else { - if (commonDefaultKey != null) { - return false; - } - if (commonSpecifiedKey == null) { - commonSpecifiedKey = persistentAttribute.getMappingKey(); - } - else if (!commonSpecifiedKey.equals(persistentAttribute.getMappingKey())) { - return false; - } - } - } - if (handlerSpecifiedMappingKey != null) { - return handlerSpecifiedMappingKey.equals(commonSpecifiedKey); - } - else if (handlerDefaultMappingKey != null) { - return handlerDefaultMappingKey.equals(commonDefaultKey); - } - return false; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentTypeMapAsHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentTypeMapAsHandler.java deleted file mode 100644 index 726461f01c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentTypeMapAsHandler.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.commands; - -import java.util.Iterator; -import java.util.Map; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.ui.internal.menus.PersistentTypeMapAsContribution; -import org.eclipse.ui.ISources; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.commands.IElementUpdater; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.menus.UIElement; -import org.eclipse.ui.services.IEvaluationService; - -/** - * This handler is responsible to change the mapping type of the selected - * <code>PersistentType</code>. - * <p> - * This handler is defined in the JPT plugin.xml. It will be invoked by the - * mapping action dynamically created by the <code>PersistentTypeMapAsContribution</code>. - * - * @see PersistentType - * @see PersistentTypeMapAsContribution - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class PersistentTypeMapAsHandler extends AbstractHandler - implements IElementUpdater -{ - /** - * The unique identifier of the Map As command used for {@link PersistentType} - * defined in the <code>JptJpaUiPlugin</code> plugin.xml. - */ - public static final String COMMAND_ID = "org.eclipse.jpt.jpa.ui.persistentTypeMapAs"; - - /** - * The unique identifier of the Map As command parameter used for {@link PersistentType} - * defined in the <code>JptJpaUiPlugin</code> plugin.xml. - */ - public static final String COMMAND_PARAMETER_ID = "persistentTypeMappingKey"; - - - /** - * Creates a new <code>PersistentTypeMapAsHandler</code>. - */ - public PersistentTypeMapAsHandler() { - super(); - } - - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Retrieve the selection from the ExecutionEvent - IStructuredSelection selection = (IStructuredSelection) - HandlerUtil.getCurrentSelectionChecked(event); - - // Retrieve the value of the unique parameter passed to the command - String mappingKey = event.getParameter(COMMAND_PARAMETER_ID); - - // Change the mapping key for all the selected items - for (Object item : selection.toArray()) { - PersistentType type = (PersistentType) item; - type.setMappingKey(mappingKey); - } - - return null; - } - - @SuppressWarnings("unchecked") - public void updateElement(UIElement element, Map parameters) { - // Retrieve the selection for the UIElement - - // Due to Bug 226746, we have to use API workaround to retrieve current - // selection - IEvaluationService es - = (IEvaluationService) element.getServiceLocator().getService(IEvaluationService.class); - IViewPart part = - (IViewPart) es.getCurrentState().getVariable(ISources.ACTIVE_PART_NAME); - IStructuredSelection selection - = (IStructuredSelection) part.getSite().getSelectionProvider().getSelection(); - - String commonMappingKey = commonMappingKey(selection); - - String handlerMappingKey = (String) parameters.get(COMMAND_PARAMETER_ID); - if (handlerMappingKey != null) { - element.setChecked(handlerMappingKey.equals(commonMappingKey)); - } - } - - @SuppressWarnings("unchecked") - protected String commonMappingKey(IStructuredSelection selection) { - String commonKey = null; - for (Iterator stream = selection.iterator(); stream.hasNext(); ) { - Object obj = stream.next(); - - if (! (obj instanceof PersistentType)) { - return null; - } - - PersistentType persistentType = (PersistentType) obj; - - if (commonKey == null) { - commonKey = persistentType.getMappingKey(); - } - else if (! commonKey.equals(persistentType.getMappingKey())) { - return null; - } - } - return commonKey; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/RemovePersistentAttributeFromXmlHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/RemovePersistentAttributeFromXmlHandler.java deleted file mode 100644 index 49e4e16826..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/RemovePersistentAttributeFromXmlHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.commands; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; - -public class RemovePersistentAttributeFromXmlHandler extends AbstractHandler -{ - @SuppressWarnings("unchecked") - public Object execute(ExecutionEvent executionEvent) throws ExecutionException { - final IWorkbenchWindow window = - HandlerUtil.getActiveWorkbenchWindowChecked(executionEvent); - - final List<OrmReadOnlyPersistentAttribute> virtualAttributes = new ArrayList<OrmReadOnlyPersistentAttribute>(); - - IStructuredSelection selection = - (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(executionEvent); - - // only applies for multiply selected OrmPersistentAttribute objects in a tree - for (OrmPersistentAttribute attribute : (Iterable<OrmPersistentAttribute>) CollectionTools.iterable(selection.iterator())) { - OrmReadOnlyPersistentAttribute newAttribute = attribute.convertToVirtual(); - if (newAttribute != null) { - virtualAttributes.add(newAttribute); - } - } - - if (virtualAttributes.size() == 1) { - window.getShell().getDisplay().asyncExec( - new Runnable() { - public void run() { - JpaSelectionManager selectionManager = SelectionManagerFactory.getSelectionManager(window); - selectionManager.select(new DefaultJpaSelection(virtualAttributes.get(0)), null); - } - }); - } - - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/RemovePersistentClassHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/RemovePersistentClassHandler.java deleted file mode 100644 index 8aae6fa4e4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/RemovePersistentClassHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.commands; - -import java.util.Iterator; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.ui.handlers.HandlerUtil; - -public class RemovePersistentClassHandler extends AbstractHandler -{ - @SuppressWarnings("unchecked") - public Object execute(ExecutionEvent executionEvent) throws ExecutionException { - IStructuredSelection selection = - (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(executionEvent); - - // only applies for multiply selected OrmPersistentType objects in a tree - for (Iterator<OrmPersistentType> stream = selection.iterator(); stream.hasNext(); ) { - OrmPersistentType persistentType = stream.next(); - ((EntityMappings) persistentType.getMappingFileRoot()).removePersistentType(persistentType); - } - - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java deleted file mode 100644 index b56c54c3cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.XmlFile; -import org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.ui.handlers.HandlerUtil; - -public class UpgradeXmlFileVersionHandler extends AbstractHandler -{ - public Object execute(ExecutionEvent event) throws ExecutionException { - IStructuredSelection selection - = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event); - - for (Object selectedObject : selection.toArray()) { - upgradeXmlFileVersion(selectedObject); - } - return null; - } - - protected void upgradeXmlFileVersion(Object selectedObject) { - JpaXmlResource xmlResource = - (JpaXmlResource) Platform.getAdapterManager().getAdapter(selectedObject, JpaXmlResource.class); - if (xmlResource == null) { - XmlFile xmlFile = - (XmlFile) Platform.getAdapterManager().getAdapter(selectedObject, XmlFile.class); - if (xmlFile != null) { - xmlResource = xmlFile.getXmlResource(); - } - } - if (xmlResource == null) { - return; - } - - final JpaRootEObject root = xmlResource.getRootObject(); - IContentType contentType = xmlResource.getContentType(); - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(xmlResource.getProject()); - final String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion(); - - xmlResource.modify( - new Runnable() { - public void run() { - root.setVersion(newVersion); - } - }); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractBasicMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractBasicMappingComposite.java deleted file mode 100644 index 75b58f72ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractBasicMappingComposite.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.jpt.jpa.core.context.Column; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.ConvertibleMapping; -import org.eclipse.jpt.jpa.core.context.EnumeratedConverter; -import org.eclipse.jpt.jpa.core.context.LobConverter; -import org.eclipse.jpt.jpa.core.context.TemporalConverter; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | EnumTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | LobComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see BasicMapping - * @see ColumnComposite - * @see EnumTypeComposite - * @see FetchTypeComposite - * @see LobComposite - * @see OptionalComposite - * @see TemporalTypeComposite - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractBasicMappingComposite<T extends BasicMapping> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>BasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IBasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractBasicMappingComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeBasicCollapsibleSection(container); - initializeTypeCollapsibleSection(container); - } - - protected void initializeBasicCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.BasicSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeBasicSection(container); - } - - protected void initializeBasicSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, addSubPane(container, 4)); - } - - protected void initializeTypeCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.TypeSection_type - ); - this.initializeTypeSection(container); - } - - protected void initializeTypeSection(Composite container) { - ((GridLayout) container.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_default, - buildConverterBooleanHolder(null), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - // Lob - Button lobButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_lob, - buildConverterBooleanHolder(LobConverter.class), - null); - ((GridData) lobButton.getLayoutData()).horizontalSpan = 2; - - PropertyValueModel<Converter> converterHolder = buildConverterHolder(); - // Temporal - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_temporal, - buildConverterBooleanHolder(TemporalConverter.class), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(converterHolder), container, getWidgetFactory())); - - - // Enumerated - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_enumerated, - buildConverterBooleanHolder(EnumeratedConverter.class), - null); - registerSubPane(new EnumTypeComposite(buildEnumeratedConverterHolder(converterHolder), container, getWidgetFactory())); - } - - protected PropertyValueModel<Column> buildColumnHolder() { - return new TransformationPropertyValueModel<T, Column>(getSubjectHolder()) { - @Override - protected Column transform_(T value) { - return value.getColumn(); - } - }; - } - - protected PropertyValueModel<Converter> buildConverterHolder() { - return new PropertyAspectAdapter<T, Converter>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getConverter(); - } - }; - } - - protected PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return converter.getType() == TemporalConverter.class ? (TemporalConverter) converter : null; - } - }; - } - - protected PropertyValueModel<EnumeratedConverter> buildEnumeratedConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, EnumeratedConverter>(converterHolder) { - @Override - protected EnumeratedConverter transform_(Converter converter) { - return converter.getType() == EnumeratedConverter.class ? (EnumeratedConverter) converter : null; - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildConverterBooleanHolder(final Class<? extends Converter> converterType) { - return new PropertyAspectAdapter<BasicMapping, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getConverter(); - return Boolean.valueOf(converter.getType() == converterType); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(converterType); - } - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractBasicMappingUiDefinition.java deleted file mode 100644 index f0ef46dffc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractBasicMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractBasicMappingUiDefinition<M, T extends BasicMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractBasicMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.BasicMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.BasicMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddableComposite.java deleted file mode 100644 index cd59441aea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddableComposite.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Embeddable; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * This pane does not have any widgets. - * - * @see Embeddable - * @see JavaUiFactory - The factory creating this pane - * @see EmbeddableUiProvider - * - * @version 2.3 - * @since 2.1 - */ -public abstract class AbstractEmbeddableComposite<T extends Embeddable> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddableComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractEmbeddableComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - } - - protected void initializeEmbeddableCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.EmbeddableSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeEmbeddableSection(container); - } - - protected void initializeEmbeddableSection(Composite container) { - - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddableUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddableUiDefinition.java deleted file mode 100644 index 985eb31d32..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddableUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.Embeddable; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractEmbeddableUiDefinition<M, T extends Embeddable> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractEmbeddableUiDefinition() { - super(); - } - - - public String getKey() { - return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY; - } - - public String getLabel() { - return JptUiDetailsMessages.EmbeddableUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.EmbeddableUiProvider_linkLabel; - } - - public Image getImage() { - return JpaMappingImageHelper.imageForTypeMapping(getKey()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedIdMappingComposite.java deleted file mode 100644 index 0fc0e5137b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedIdMappingComposite.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractEmbeddedIdMappingComposite<T extends EmbeddedIdMapping> - extends Pane<T> - implements JpaComposite -{ - protected AbstractEmbeddedIdMappingComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) { - initializeEmbeddedIdCollapsibleSection(container); - } - - protected void initializeEmbeddedIdCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.EmbeddedIdSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - this.initializeEmbeddedIdSection(container); - } - - protected abstract void initializeEmbeddedIdSection(Composite container); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedIdMappingUiDefinition.java deleted file mode 100644 index 142fe12e4e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedIdMappingUiDefinition.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - - -public abstract class AbstractEmbeddedIdMappingUiDefinition<M, T extends EmbeddedIdMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractEmbeddedIdMappingUiDefinition() { - super(); - } - - - public String getKey() { - return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY; - } - - public String getLabel() { - return JptUiDetailsMessages.EmbeddedIdMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.EmbeddedIdMappingUiProvider_linkLabel; - } - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingComposite.java deleted file mode 100644 index 8aedf8ec83..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingComposite.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractEmbeddedMappingComposite<T extends EmbeddedMapping> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddedMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>EmbeddedMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractEmbeddedMappingComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeEmbeddedCollapsibleSection(container); - } - - protected void initializeEmbeddedCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.EmbeddedSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeEmbeddedSection(container); - } - - protected void initializeEmbeddedSection(Composite container) { - new EmbeddedMappingOverridesComposite( - this, - container - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingOverridesComposite.java deleted file mode 100644 index 8311fd4897..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingOverridesComposite.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.BaseEmbeddedMapping; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractEmbeddedMappingOverridesComposite<T extends BaseEmbeddedMapping> - extends AbstractOverridesComposite<T> -{ - protected AbstractEmbeddedMappingOverridesComposite( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder() { - return new PropertyAspectAdapter<T, AttributeOverrideContainer>(getSubjectHolder()) { - @Override - protected AttributeOverrideContainer buildValue_() { - return this.subject.getAttributeOverrideContainer(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingUiDefinition.java deleted file mode 100644 index f699c1a6e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.EmbeddedMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractEmbeddedMappingUiDefinition<M, T extends EmbeddedMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractEmbeddedMappingUiDefinition() { - super(); - } - - - public String getKey() { - return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; - } - - public String getLabel() { - return JptUiDetailsMessages.EmbeddedMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel; - } - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityComposite.java deleted file mode 100644 index 56219a0784..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityComposite.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.core.context.IdClassReference; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EntityNameComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TableComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | IdClassComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | - v Attribute Overrides ------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | - v Secondary Tables ---------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | Pane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | - v Inheritance --------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | InheritanceComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | - v Queries ------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | QueriesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | - v Generators ---------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | GeneratorsComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see EntityNameComposite - * @see InheritanceComposite - * @see IdClassComposite - * @see EntityOverridesComposite - * @see TableComposite - * @see GenerationComposite - * - * TODO talk to JavaEditor people about what we can do to hook in TabbedProperties for the JavaEditor - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractEntityComposite<T extends Entity> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>AbstractEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractEntityComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - protected abstract void initializeSecondaryTablesSection(Composite container); - - protected abstract void initializeInheritanceSection(Composite container); - - @Override - protected void initializeLayout(Composite container) { - this.initializeEntityCollapsibleSection(container); - this.initializeQueriesCollapsibleSection(container); - this.initializeInheritanceCollapsibleSection(container); - this.initializeAttributeOverridesCollapsibleSection(container); - this.initializeGeneratorsCollapsibleSection(container); - this.initializeSecondaryTablesCollapsibleSection(container); - } - - protected void initializeEntityCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.EntitySection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeEntitySection(container); - } - - protected void initializeEntitySection(Composite container) { - new TableComposite(this, container); - new EntityNameComposite(this, container); - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - } - - protected PropertyValueModel<IdClassReference> buildIdClassReferenceHolder() { - return new PropertyAspectAdapter<Entity, IdClassReference>(getSubjectHolder()) { - @Override - protected IdClassReference buildValue_() { - return this.subject.getIdClassReference(); - } - }; - } - - protected void initializeQueriesCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.EntityComposite_queries); - this.initializeQueriesSection(container, buildQueryContainerHolder()); - } - - protected void initializeQueriesSection(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) { - new QueriesComposite(this, queryContainerHolder, container); - } - - private PropertyValueModel<QueryContainer> buildQueryContainerHolder() { - return new PropertyAspectAdapter<Entity, QueryContainer>(getSubjectHolder()) { - @Override - protected QueryContainer buildValue_() { - return this.subject.getQueryContainer(); - } - }; - } - - protected void initializeAttributeOverridesCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.OverridesComposite_attributeOverridesSection); - initializeAttributeOverridesSection(container); - } - - protected void initializeAttributeOverridesSection(Composite container) { - new EntityOverridesComposite(this, container); - } - - protected void initializeInheritanceCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.EntityComposite_inheritance); - initializeInheritanceSection(container); - } - - protected void initializeGeneratorsCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.IdMappingComposite_primaryKeyGenerationSection); - initializeGeneratorsSection(container, buildGeneratorContainer()); - } - - protected void initializeGeneratorsSection(Composite container, PropertyValueModel<GeneratorContainer> generatorContainerHolder) { - new GenerationComposite(this, generatorContainerHolder, container); - } - - private PropertyValueModel<GeneratorContainer> buildGeneratorContainer() { - return new PropertyAspectAdapter<Entity, GeneratorContainer>(getSubjectHolder()) { - @Override - protected GeneratorContainer buildValue_() { - return this.subject.getGeneratorContainer(); - } - }; - } - - protected void initializeSecondaryTablesCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.SecondaryTablesComposite_secondaryTables); - initializeSecondaryTablesSection(container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityMappingsDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityMappingsDetailsProvider.java deleted file mode 100644 index 163c5f8163..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityMappingsDetailsProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmStructureNodes; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; - -public abstract class AbstractEntityMappingsDetailsProvider - implements JpaDetailsProvider -{ - protected AbstractEntityMappingsDetailsProvider() { - super(); - } - - - public final boolean providesDetails(JpaStructureNode structureNode) { - return Tools.valuesAreEqual(structureNode.getId(), OrmStructureNodes.ENTITY_MAPPINGS_ID) - && providesDetails(structureNode.getResourceType()); - } - - protected abstract boolean providesDetails(JptResourceType resourceType); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityOverridesComposite.java deleted file mode 100644 index 5bbc73260d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityOverridesComposite.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractEntityOverridesComposite - extends AbstractOverridesComposite<Entity> -{ - protected AbstractEntityOverridesComposite( - Pane<? extends Entity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected boolean supportsAssociationOverrides() { - return true; - } - - @Override - protected PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder() { - return new PropertyAspectAdapter<Entity, AttributeOverrideContainer>(getSubjectHolder()) { - @Override - protected AttributeOverrideContainer buildValue_() { - return this.subject.getAttributeOverrideContainer(); - } - }; - } - - @Override - protected PropertyValueModel<AssociationOverrideContainer> buildAssociationOverrideContainerHolder() { - return new PropertyAspectAdapter<Entity, AssociationOverrideContainer>(getSubjectHolder()) { - @Override - protected AssociationOverrideContainer buildValue_() { - return this.subject.getAssociationOverrideContainer(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityUiDefinition.java deleted file mode 100644 index 1dae9012f0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractEntityUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractEntityUiDefinition<M, T extends Entity> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractEntityUiDefinition() { - super(); - } - - - public String getKey() { - return MappingKeys.ENTITY_TYPE_MAPPING_KEY; - } - - public String getLabel() { - return JptUiDetailsMessages.EntityUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.EntityUiProvider_linkLabel; - } - - public Image getImage() { - return JpaMappingImageHelper.imageForTypeMapping(getKey()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractIdMappingComposite.java deleted file mode 100644 index 7e3b188e7f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractIdMappingComposite.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Column; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.ConvertibleMapping; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.TemporalConverter; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractIdMappingComposite<T extends IdMapping> - extends Pane<T> - implements JpaComposite -{ - public AbstractIdMappingComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) { - initializeIdCollapsibleSection(container); - initializeTypeCollapsibleSection(container); - initializeGenerationCollapsibleSection(container); - } - - protected void initializeIdCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.IdSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - this.initializeIdSection(container); - } - - protected abstract void initializeIdSection(Composite container); - - protected void initializeTypeCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.TypeSection_type); - this.initializeTypeSection(container); - } - - protected void initializeTypeSection(Composite container) { - ((GridLayout) container.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_default, - buildConverterBooleanHolder(null), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - PropertyValueModel<Converter> converterHolder = buildConverterHolder(); - // Temporal - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_temporal, - buildConverterBooleanHolder(TemporalConverter.class), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(converterHolder), container, getWidgetFactory())); - } - - protected void initializeGenerationCollapsibleSection(Composite container) { - new IdMappingGenerationComposite(this, container); - } - - protected PropertyValueModel<? extends Column> buildColumnHolder() { - return new TransformationPropertyValueModel<T, Column>(getSubjectHolder()) { - @Override - protected Column transform_(T value) { - return value.getColumn(); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildConverterBooleanHolder(final Class<? extends Converter> converterType) { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getConverter(); - return Boolean.valueOf(converter.getType() == converterType); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(converterType); - } - } - }; - } - - protected PropertyValueModel<Converter> buildConverterHolder() { - return new PropertyAspectAdapter<T, Converter>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getConverter(); - } - }; - } - - protected PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return converter.getType() == TemporalConverter.class ? (TemporalConverter) converter : null; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractIdMappingUiDefinition.java deleted file mode 100644 index 32a63a31bb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractIdMappingUiDefinition.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - - -public abstract class AbstractIdMappingUiDefinition<M, T extends IdMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractIdMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.IdMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.IdMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractInheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractInheritanceComposite.java deleted file mode 100644 index 095cea3979..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractInheritanceComposite.java +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.InheritanceType; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ---------------------------------------------------- | - * | Strategy: | EnumComboViewer |v| | - * | ---------------------------------------------------- | - * | ---------------------------------------------------- | - * | Value: | I |v| | - * | ---------------------------------------------------- | - * | | - * | > Discriminator Column | - * | | - * | ---------------------------------------------------- | - * | Name: | ColumnCombo |v| | - * | ---------------------------------------------------- | - * | ---------------------------------------------------- | - * | Type: | EnumComboViewer |v| | - * | ---------------------------------------------------- | - * | ---------------------------------------------------- | - * | Column Definition: | I | | - * | ---------------------------------------------------- | - * | ------------- | - * | Length: | I |I| | - * | ------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PrimaryKeyJoinColumnsComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see AbstractEntityComposite - The parent container - * @see ColumnCombo - * @see EnumComboViewer - * @see PrimaryKeyJoinColumnsComposite - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public abstract class AbstractInheritanceComposite<T extends Entity> extends Pane<T> { - - /** - * A key used to represent the default value, this is required to convert - * the selected item from a combo to <code>null</code>. This key is most - * likely never typed the user and it will help to convert the value to - * <code>null</code> when it's time to set the new selected value into the - * model. - */ - protected static String DEFAULT_KEY = "?!#!?#?#?default?#?!#?!#?"; - - protected static String NONE_KEY = "?!#!?#?#?none?#?!#?!#?"; - - /** - * Creates a new <code>InheritanceComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public AbstractInheritanceComposite(Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = getGroupBoxMargin(); - - Composite subPane = addSubPane( - container, 0, groupBoxMargin, 0, groupBoxMargin - ); - - // Strategy widgets - addLabeledComposite( - subPane, - JptUiDetailsMessages.InheritanceComposite_strategy, - addStrategyCombo(subPane), - JpaHelpContextIds.ENTITY_INHERITANCE_STRATEGY - ); - - // Discrinator Value widgets - PropertyValueModel<Boolean> dvEnabled = this.buildDiscriminatorValueEnabledHolder(); - Combo discriminatorValueCombo = addEditableCombo( - subPane, - buildDiscriminatorValueListHolder(), - buildDiscriminatorValueHolder(), - buildDiscriminatorValueConverter(), - dvEnabled - ); - Label discriminatorValueLabel = addLabel( - subPane, - JptUiDetailsMessages.InheritanceComposite_discriminatorValue, - dvEnabled - ); - addLabeledComposite( - subPane, - discriminatorValueLabel, - discriminatorValueCombo, - null, - JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_VALUE - ); - - new DiscriminatorColumnComposite<Entity>(this, container); - - // Primary Key Join Columns widgets - addPrimaryKeyJoinColumnsComposite(addSubPane(container, 5)); - } - - protected WritablePropertyValueModel<Boolean> buildDiscriminatorValueEnabledHolder() { - return new PropertyAspectAdapter<Entity, Boolean>(getSubjectHolder(), Entity.SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.specifiedDiscriminatorValueIsAllowed()); - } - }; - } - - private ListValueModel<String> buildDefaultDiscriminatorListValueHolder() { - return new PropertyListValueModelAdapter<String>( - buildDefaultDiscriminatorValueHolder() - ); - } - - private WritablePropertyValueModel<String> buildDefaultDiscriminatorValueHolder() { - return new PropertyAspectAdapter<Entity, String>(getSubjectHolder(), Entity.DEFAULT_DISCRIMINATOR_VALUE_PROPERTY, Entity.DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY) { - @Override - protected String buildValue_() { - String value = this.subject.getDefaultDiscriminatorValue(); - if (value == null && this.subject.discriminatorValueIsUndefined()) { - return NONE_KEY; - } - - if (value == null) { - value = DEFAULT_KEY; - } - else { - value = DEFAULT_KEY + value; - } - - return value; - } - }; - } - - private StringConverter<String> buildDiscriminatorValueConverter() { - return new StringConverter<String>() { - public String convertToString(String value) { - - if (getSubject() == null) { - //this is part of a list given to a combo, combos don't take kindly to null - return JptCommonUiMessages.NoneSelected; - } - - if (value == null) { - value = getSubject().getDefaultDiscriminatorValue(); - if (value == null && getSubject().discriminatorValueIsUndefined()) { - value = NONE_KEY; - } - else { - value = (value != null) ? - DEFAULT_KEY + value - : - DEFAULT_KEY; - } - } - if (value.startsWith(DEFAULT_KEY)) { - String defaultName = value.substring(DEFAULT_KEY.length()); - - if (defaultName.length() > 0) { - value = NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - defaultName - ); - } - else { - value = JptUiDetailsMessages.ProviderDefault; - } - } - if (value.startsWith(NONE_KEY)) { - value = JptCommonUiMessages.NoneSelected; - } - return value; - } - }; - } - - private WritablePropertyValueModel<String> buildDiscriminatorValueHolder() { - return new PropertyAspectAdapter<Entity, String>(getSubjectHolder(), Entity.SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getSpecifiedDiscriminatorValue(); - } - - @Override - protected void setValue_(String value) { - - // Convert the default value or an empty string to null - if ((value != null) && - ((value.length() == 0) || value.startsWith(DEFAULT_KEY) || value.startsWith(NONE_KEY))) { - - value = null; - } - - this.subject.setSpecifiedDiscriminatorValue(value); - } - }; - } - - private ListValueModel<String> buildDiscriminatorValueListHolder() { - return buildDefaultDiscriminatorListValueHolder(); - } - - private EnumFormComboViewer<Entity, InheritanceType> addStrategyCombo(Composite container) { - - return new EnumFormComboViewer<Entity, InheritanceType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(Entity.DEFAULT_INHERITANCE_STRATEGY_PROPERTY); - propertyNames.add(Entity.SPECIFIED_INHERITANCE_STRATEGY_PROPERTY); - } - - @Override - protected InheritanceType[] getChoices() { - return InheritanceType.values(); - } - - @Override - protected InheritanceType getDefaultValue() { - return getSubject().getDefaultInheritanceStrategy(); - } - - @Override - protected String displayString(InheritanceType value) { - return buildDisplayString( - JptUiDetailsMessages.class, - AbstractInheritanceComposite.class, - value - ); - } - - @Override - protected InheritanceType getValue() { - return getSubject().getSpecifiedInheritanceStrategy(); - } - - @Override - protected void setValue(InheritanceType value) { - getSubject().setSpecifiedInheritanceStrategy(value); - } - }; - } - - protected abstract void addPrimaryKeyJoinColumnsComposite(Composite container); - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractJoiningStrategyPane.java deleted file mode 100644 index bb05a6a391..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractJoiningStrategyPane.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.MappedByRelationship; -import org.eclipse.jpt.jpa.core.context.MappedByRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationshipStrategy; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -/** - * Abstract superclass for joining strategy form panes - * - * Here is the basic layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o <label> _______________________________________________________________ | - * | | | | - * | | (joining strategy details composite) | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see MappedByRelationship - * @see MappedByRelationshipStrategy - * @see OneToOneJoiningStrategyPane - * - * @version 2.3 - * @since 2.1 - */ -public abstract class AbstractJoiningStrategyPane - <R extends ReadOnlyRelationship, S extends ReadOnlyRelationshipStrategy> - extends Pane<R> -{ - protected Composite strategyDetailsComposite; - - - /** - * Creates a new <code>AbstractJoiningStrategyPane</code>. - * - * @param parentPane The parent form pane - * @param parent The parent container - */ - protected AbstractJoiningStrategyPane( - Pane<? extends R> parentPane, - Composite parent) { - super(parentPane, parent); - } - - protected AbstractJoiningStrategyPane(Pane<?> parentPane, - PropertyValueModel<? extends R> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - protected abstract WritablePropertyValueModel<Boolean> buildUsesStrategyHolder(); - - - @Override - protected void initializeLayout(Composite container) { - PageBook pageBook = new PageBook(container, SWT.NULL); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalIndent = 5; - pageBook.setLayoutData(gd); - - this.strategyDetailsComposite = buildStrategyDetailsComposite(pageBook); - - new ControlSwitcher(this.buildUsesStrategyHolder(), buildPageBookTransformer(), pageBook); - } - - protected abstract Composite buildStrategyDetailsComposite(Composite parent); - - protected Transformer<Boolean, Control> buildPageBookTransformer() { - return new Transformer<Boolean, Control>() { - public Control transform(Boolean usesStrategy) { - return (usesStrategy.booleanValue()) ? - AbstractJoiningStrategyPane.this.strategyDetailsComposite : - null; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractJpaDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractJpaDetailsPage.java deleted file mode 100644 index 92261db5f3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractJpaDetailsPage.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.swt.widgets.Composite; - -/** - * The base class for the details view. - * - * @see JpaStructureNode - * - * @version 3.0 - * @since 1.0 - */ -public abstract class AbstractJpaDetailsPage<T extends JpaStructureNode> - extends Pane<T> - implements JpaDetailsPage<T> -{ - /** - * Creates a new <code>BaseJpaDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractJpaDetailsPage(Composite parent, WidgetFactory widgetFactory) { - super(new SimplePropertyValueModel<T>(), parent, widgetFactory); - } - - protected JpaPlatformUi getJpaPlatformUi() { - String platformId = getSubject().getJpaProject().getJpaPlatform().getId(); - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(platformId); - } - - public final void setSubject(T subject) { - WritablePropertyValueModel<T> subjectHolder = (WritablePropertyValueModel<T>) getSubjectHolder(); - subjectHolder.setValue(subject); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToManyMappingComposite.java deleted file mode 100644 index 60fff9a731..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToManyMappingComposite.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.Cascade; -import org.eclipse.jpt.jpa.core.context.ManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.ManyToManyRelationship; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrderingComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToManyMapping} - * @see {@link TargetEntityComposite} - * @see {@link ManyToManyJoiningStrategyPane} - * @see {@link FetchTypeComposite} - * @see {@link CascadeComposite} - * @see {@link OrderingComposite} - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractManyToManyMappingComposite<T extends ManyToManyMapping, R extends ManyToManyRelationship> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>ManyToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IManyToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractManyToManyMappingComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeManyToManyCollapsibleSection(container); - initializeJoiningStrategyCollapsibleSection(container); - initializeOrderingCollapsibleSection(container); - } - - protected void initializeManyToManyCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.ManyToManySection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeManyToManySection(container); - } - - protected abstract void initializeManyToManySection(Composite container); - - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new ManyToManyJoiningStrategyPane(this, buildJoiningHolder(), container); - } - - protected void initializeOrderingCollapsibleSection(Composite container) { - new OrderingComposite(this, container); - } - - - protected PropertyValueModel<R> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, R>( - getSubjectHolder()) { - @SuppressWarnings("unchecked") - @Override - protected R transform_(T value) { - return (R) value.getRelationship(); - } - }; - } - - protected PropertyValueModel<Cascade> buildCascadeHolder() { - return new TransformationPropertyValueModel<T, Cascade>(getSubjectHolder()) { - @Override - protected Cascade transform_(T value) { - return value.getCascade(); - } - }; - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<T, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToManyMappingUiDefinition.java deleted file mode 100644 index 331af34391..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToManyMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.ManyToManyMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractManyToManyMappingUiDefinition<M, T extends ManyToManyMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractManyToManyMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.ManyToManyMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToOneMappingComposite.java deleted file mode 100644 index c72c170e37..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToOneMappingComposite.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Cascade; -import org.eclipse.jpt.jpa.core.context.ManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.ManyToOneRelationship; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractManyToOneMappingComposite<T extends ManyToOneMapping, R extends ManyToOneRelationship> - extends Pane<T> - implements JpaComposite -{ - protected AbstractManyToOneMappingComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeManyToOneCollapsibleSection(container); - initializeJoiningStrategyCollapsibleSection(container); - } - - protected void initializeManyToOneCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.ManyToOneSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeManyToOneSection(container); - } - - protected abstract void initializeManyToOneSection(Composite container); - - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new ManyToOneJoiningStrategyPane(this, buildJoiningHolder(), container); - } - - protected PropertyValueModel<Cascade> buildCascadeHolder() { - return new TransformationPropertyValueModel<T, Cascade>(getSubjectHolder()) { - @Override - protected Cascade transform_(T value) { - return value.getCascade(); - } - }; - } - - protected PropertyValueModel<R> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, R>( - getSubjectHolder()) { - @SuppressWarnings("unchecked") - @Override - protected R transform_(T value) { - return (R) value.getRelationship(); - } - }; - } - - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToOneMappingUiDefinition.java deleted file mode 100644 index 74635a0651..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractManyToOneMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.ManyToOneMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractManyToOneMappingUiDefinition<M, T extends ManyToOneMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractManyToOneMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.ManyToOneMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappedSuperclassComposite.java deleted file mode 100644 index c9b29c24d8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappedSuperclassComposite.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.IdClassReference; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - - -public abstract class AbstractMappedSuperclassComposite<T extends MappedSuperclass> - extends Pane<T> - implements JpaComposite -{ - protected AbstractMappedSuperclassComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - this.initializeMappedSuperclassCollapsibleSection(container); - } - - protected void initializeMappedSuperclassCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.MappedSuperclassSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeMappedSuperclassSection(container); - } - - protected void initializeMappedSuperclassSection(Composite container) { - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - } - - protected PropertyValueModel<IdClassReference> buildIdClassReferenceHolder() { - return new PropertyAspectAdapter<T, IdClassReference>(getSubjectHolder()) { - @Override - protected IdClassReference buildValue_() { - return this.subject.getIdClassReference(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappedSuperclassUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappedSuperclassUiDefinition.java deleted file mode 100644 index 2d76a0b67b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappedSuperclassUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractMappedSuperclassUiDefinition<M, T extends MappedSuperclass> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractMappedSuperclassUiDefinition() { - super(); - } - - - public String getKey() { - return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY; - } - - public String getLabel() { - return JptUiDetailsMessages.MappedSuperclassUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.MappedSuperclassUiProvider_linkLabel; - } - - public Image getImage() { - return JpaMappingImageHelper.imageForTypeMapping(getKey()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappingUiDefinition.java deleted file mode 100644 index 54562e5693..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractMappingUiDefinition.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; - -public abstract class AbstractMappingUiDefinition<M, T> - implements MappingUiDefinition<M, T> -{ - protected AbstractMappingUiDefinition() { - super(); - } - - - public boolean isEnabledFor(M mappableObject) { - return true; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToManyMappingComposite.java deleted file mode 100644 index f1511e6ef2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToManyMappingComposite.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Cascade; -import org.eclipse.jpt.jpa.core.context.OneToManyMapping; -import org.eclipse.jpt.jpa.core.context.OneToManyRelationship; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrderingComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OneToManyMapping - * @see CascadeComposite - * @see FetchTypeComposite - * @see JoinTableComposite - * @see OrderingComposite - * @see TargetEntityComposite - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractOneToManyMappingComposite<T extends OneToManyMapping, R extends OneToManyRelationship> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>OneToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IOneToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractOneToManyMappingComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeOneToManyCollapsibleSection(container); - initializeJoiningStrategyCollapsibleSection(container); - initializeOrderingCollapsibleSection(container); - } - - protected void initializeOneToManyCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.OneToManySection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeOneToManySection(container); - } - - protected abstract void initializeOneToManySection(Composite container); - - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new OneToManyJoiningStrategyPane(this, buildJoiningHolder(), container); - } - - protected void initializeOrderingCollapsibleSection(Composite container) { - new OrderingComposite(this, container); - } - - protected PropertyValueModel<R> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, R>(getSubjectHolder()) { - @SuppressWarnings("unchecked") - @Override - protected R transform_(T value) { - return (R) value.getRelationship(); - } - }; - } - - protected PropertyValueModel<Cascade> buildCascadeHolder() { - return new TransformationPropertyValueModel<T, Cascade>(getSubjectHolder()) { - @Override - protected Cascade transform_(T value) { - return value.getCascade(); - } - }; - } - - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToManyMappingUiDefinition.java deleted file mode 100644 index 26680dbc0d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToManyMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.OneToManyMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractOneToManyMappingUiDefinition<M, T extends OneToManyMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractOneToManyMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.OneToManyMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToOneMappingComposite.java deleted file mode 100644 index 0ed720721c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToOneMappingComposite.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Cascade; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.core.context.OneToOneRelationship; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractOneToOneMappingComposite<T extends OneToOneMapping, R extends OneToOneRelationship> - extends Pane<T> - implements JpaComposite -{ - protected AbstractOneToOneMappingComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeOneToOneCollapsibleSection(container); - initializeJoiningStrategyCollapsibleSection(container); - } - - protected void initializeOneToOneCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.OneToOneSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeOneToOneSection(container); - } - - protected abstract void initializeOneToOneSection(Composite container); - - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new OneToOneJoiningStrategyPane(this, buildJoiningHolder(), container); - } - - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - } - - protected PropertyValueModel<R> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, R>( - getSubjectHolder()) { - @SuppressWarnings("unchecked") - @Override - protected R transform_(T value) { - return (R) value.getRelationship(); - } - }; - } - - protected PropertyValueModel<Cascade> buildCascadeHolder() { - return new TransformationPropertyValueModel<T, Cascade>(getSubjectHolder()) { - @Override - protected Cascade transform_(T value) { - return value.getCascade(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToOneMappingUiDefinition.java deleted file mode 100644 index 133ad70daa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOneToOneMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractOneToOneMappingUiDefinition<M, T extends OneToOneMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractOneToOneMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.OneToOneMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOrderingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOrderingComposite.java deleted file mode 100644 index 00d7beacd4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOrderingComposite.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.CollectionMapping; -import org.eclipse.jpt.jpa.core.context.Orderable; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Ordering -------------------------------------------------------------- | - * | | | | - * | | o None | | - * | | | | - * | | o Primary Key | | - * | | | | - * | | o Custom | | - * | | ------------------------------------------------------------------- | | - * | | | I | | | - * | | ------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see CollectionMapping - * @see ManyToManyMappingComposite - A container of this pane - * @see OneToManyMappingComposite - A container of this pane - * - * @version 3.0 - * @since 1.0 - */ -public abstract class AbstractOrderingComposite extends Pane<CollectionMapping> -{ - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - protected AbstractOrderingComposite(Pane<? extends CollectionMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IMultiRelationshipMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractOrderingComposite(PropertyValueModel<? extends CollectionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - protected PropertyValueModel<Orderable> buildOrderableHolder() { - return new PropertyAspectAdapter<CollectionMapping, Orderable>(getSubjectHolder()) { - @Override - protected Orderable buildValue_() { - return this.subject.getOrderable(); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildNoOrderingHolder(PropertyValueModel<Orderable> orderableHolder) { - return new PropertyAspectAdapter<Orderable, Boolean>(orderableHolder, Orderable.NO_ORDERING_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isNoOrdering()); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setNoOrdering(value.booleanValue()); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildPrimaryKeyOrderingHolder(PropertyValueModel<Orderable> orderableHolder) { - return new PropertyAspectAdapter<Orderable, Boolean>(orderableHolder, Orderable.PK_ORDERING_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isPkOrdering()); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setPkOrdering(value.booleanValue()); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildCustomOrderingHolder(PropertyValueModel<Orderable> orderableHolder) { - return new PropertyAspectAdapter<Orderable, Boolean>(orderableHolder, Orderable.CUSTOM_ORDERING_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isCustomOrdering()); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setCustomOrdering(value.booleanValue()); - } - }; - } - - protected WritablePropertyValueModel<String> buildSpecifiedOrderByHolder(PropertyValueModel<Orderable> orderableHolder) { - return new PropertyAspectAdapter<Orderable, String>(orderableHolder, Orderable.SPECIFIED_ORDER_BY_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getSpecifiedOrderBy(); - } - - @Override - protected void setValue_(String value) { - this.subject.setSpecifiedOrderBy(value); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOverridesComposite.java deleted file mode 100644 index 29203ce771..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractOverridesComposite.java +++ /dev/null @@ -1,414 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationWritablePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationWritablePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverride; -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.AttributeOverride; -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.core.context.OverrideContainer; -import org.eclipse.jpt.jpa.core.context.Override_; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.VirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.context.VirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.context.VirtualOverride; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -@SuppressWarnings("nls") -public abstract class AbstractOverridesComposite<T extends JpaContextNode> - extends Pane<T> -{ - private Pane<ReadOnlyAttributeOverride> attributeOverridePane; - private Pane<ReadOnlyAssociationOverride> associationOverridePane; - - private WritablePropertyValueModel<ReadOnlyOverride> selectedOverrideHolder; - private WritablePropertyValueModel<Boolean> overrideVirtualOverrideHolder; - - - protected AbstractOverridesComposite( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - - @Override - protected void initialize() { - super.initialize(); - this.selectedOverrideHolder = buildSelectedOverrideHolder(); - } - - private WritablePropertyValueModel<ReadOnlyOverride> buildSelectedOverrideHolder() { - return new SimplePropertyValueModel<ReadOnlyOverride>(); - } - - protected abstract boolean supportsAssociationOverrides(); - - @Override - protected void initializeLayout(Composite container) { - // Overrides group pane - container = addTitledGroup( - container, - JptUiDetailsMessages.OverridesComposite_attributeOverridesGroup); - - // Overrides list pane - initializeOverridesList(container); - - int groupBoxMargin = getGroupBoxMargin(); - - // Override Default check box - Button overrideCheckBox = addCheckBox( - addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin), - JptUiDetailsMessages.OverridesComposite_overrideDefault, - getOverrideVirtualOverrideHolder(), - null); - SWTTools.controlVisibleState(buildSelectedOverrideBooleanHolder(), overrideCheckBox); - - // Property pane - PageBook pageBook = addPageBook(container); - initializeOverridePanes(pageBook); - installOverrideControlSwitcher(this.selectedOverrideHolder, pageBook); - } - - protected void initializeOverridePanes(PageBook pageBook) { - initializeAttributeOverridePane(pageBook); - if (supportsAssociationOverrides()) { - initializeAssociationOverridePane(pageBook); - } - } - - private PropertyValueModel<Boolean> buildSelectedOverrideBooleanHolder() { - return new TransformationPropertyValueModel<ReadOnlyOverride, Boolean>(this.selectedOverrideHolder) { - @Override - protected Boolean transform(ReadOnlyOverride value) { - return Boolean.valueOf(value != null); - } - }; - } - - private void initializeOverridesList(Composite container) { - new AddRemoveListPane<T>( - this, - addSubPane(container, 8), - buildOverridesAdapter(), - buildOverridesListModel(), - this.selectedOverrideHolder, - buildOverrideLabelProvider(), - JpaHelpContextIds.ENTITY_ATTRIBUTE_OVERRIDES) { - - @Override - protected void initializeButtonPane(Composite c, String helpId) { - //no buttons: no way to add/remove/edit overrides, they are all defaulted in - } - - @Override - protected void updateButtons() { - //no buttons: no way to add/remove/edit overrides, they are all defaulted in - } - }; - } - - protected void initializeAttributeOverridePane(PageBook pageBook) { - PropertyValueModel<ReadOnlyAttributeOverride> attributeOverrideHolder = buildAttributeOverrideHolder(); - this.attributeOverridePane = buildAttributeOverridePane(pageBook, attributeOverrideHolder); - installAttributeOverridePaneEnabler(this.attributeOverridePane, attributeOverrideHolder); - } - - protected Pane<ReadOnlyAttributeOverride> buildAttributeOverridePane(PageBook pageBook, PropertyValueModel<ReadOnlyAttributeOverride> attributeOverrideHolder) { - return new AttributeOverrideComposite(this, attributeOverrideHolder, pageBook); - } - - private void installAttributeOverridePaneEnabler(Pane<ReadOnlyAttributeOverride> pane, PropertyValueModel<ReadOnlyAttributeOverride> overrideHolder) { - new PaneEnabler( - buildOverrideBooleanHolder(overrideHolder), - pane); - } - - private PropertyValueModel<Boolean> buildOverrideBooleanHolder(PropertyValueModel<? extends ReadOnlyOverride> overrideHolder) { - return new CachingTransformationPropertyValueModel<ReadOnlyOverride, Boolean>(overrideHolder) { - @Override - protected Boolean transform_(ReadOnlyOverride value) { - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - protected void initializeAssociationOverridePane(PageBook pageBook) { - PropertyValueModel<ReadOnlyAssociationOverride> associationOverrideHolder = buildAssociationOverrideHolder(); - this.associationOverridePane = buildAssociationOverridePane(pageBook, associationOverrideHolder); - installAssociationOverridePaneEnabler(this.associationOverridePane, associationOverrideHolder); - } - - protected Pane<ReadOnlyAssociationOverride> buildAssociationOverridePane(PageBook pageBook, PropertyValueModel<ReadOnlyAssociationOverride> associationOverrideHolder) { - return new AssociationOverrideComposite(this, associationOverrideHolder, pageBook); - } - - private void installAssociationOverridePaneEnabler(Pane<ReadOnlyAssociationOverride> pane, PropertyValueModel<ReadOnlyAssociationOverride> overrideHolder) { - new PaneEnabler( - buildOverrideBooleanHolder(overrideHolder), - pane); - } - - private void installOverrideControlSwitcher( - PropertyValueModel<ReadOnlyOverride> overrideHolder, - PageBook pageBook) { - - new ControlSwitcher( - overrideHolder, - buildPaneTransformer(), - pageBook); - } - - private WritablePropertyValueModel<ReadOnlyAssociationOverride> buildAssociationOverrideHolder() { - return new TransformationWritablePropertyValueModel<ReadOnlyOverride, ReadOnlyAssociationOverride>(this.selectedOverrideHolder) { - @Override - protected ReadOnlyAssociationOverride transform_(ReadOnlyOverride value) { - return (value instanceof ReadOnlyAssociationOverride) ? (ReadOnlyAssociationOverride) value : null; - } - }; - } - - private WritablePropertyValueModel<ReadOnlyAttributeOverride> buildAttributeOverrideHolder() { - return new TransformationWritablePropertyValueModel<ReadOnlyOverride, ReadOnlyAttributeOverride>(this.selectedOverrideHolder) { - @Override - protected ReadOnlyAttributeOverride transform_(ReadOnlyOverride value) { - return (value instanceof ReadOnlyAttributeOverride) ? (ReadOnlyAttributeOverride) value : null; - } - }; - } - - private ListValueModel<VirtualAssociationOverride> buildDefaultAssociationOverridesListHolder(PropertyValueModel<AssociationOverrideContainer> containerHolder) { - return new ListAspectAdapter<AssociationOverrideContainer, VirtualAssociationOverride>(containerHolder, OverrideContainer.VIRTUAL_OVERRIDES_LIST) { - @Override - protected ListIterator<VirtualAssociationOverride> listIterator_() { - return new SuperListIteratorWrapper<VirtualAssociationOverride>(this.subject.virtualOverrides()); - } - - @Override - protected int size_() { - return this.subject.virtualOverridesSize(); - } - }; - } - - private ListValueModel<VirtualAttributeOverride> buildDefaultAttributeOverridesListHolder(PropertyValueModel<AttributeOverrideContainer> containerHolder) { - return new ListAspectAdapter<AttributeOverrideContainer, VirtualAttributeOverride>(containerHolder, OverrideContainer.VIRTUAL_OVERRIDES_LIST) { - @Override - protected ListIterator<VirtualAttributeOverride> listIterator_() { - return new SuperListIteratorWrapper<VirtualAttributeOverride>(this.subject.virtualOverrides()); - } - - @Override - protected int size_() { - return this.subject.virtualOverridesSize(); - } - }; - } - - protected WritablePropertyValueModel<Boolean> getOverrideVirtualOverrideHolder() { - if (this.overrideVirtualOverrideHolder == null) { - this.overrideVirtualOverrideHolder = buildOverrideVirtualOverrideHolder(); - } - return this.overrideVirtualOverrideHolder; - } - - private WritablePropertyValueModel<Boolean> buildOverrideVirtualOverrideHolder() { - return new CachingTransformationWritablePropertyValueModel<ReadOnlyOverride, Boolean>(this.selectedOverrideHolder) { - @Override - public void setValue(Boolean value) { - updateOverride(value.booleanValue()); - } - - @Override - protected Boolean transform_(ReadOnlyOverride value) { - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - String buildOverrideDisplayString(ReadOnlyOverride override) { - String overrideType; - - // Retrieve the type - if (override instanceof ReadOnlyAssociationOverride) { - overrideType = JptUiDetailsMessages.OverridesComposite_association; - } - else { - overrideType = JptUiDetailsMessages.OverridesComposite_attribute; - } - - // Format the name - String name = override.getName(); - - if (StringTools.stringIsEmpty(name)) { - name = JptUiDetailsMessages.OverridesComposite_noName; - } - - // Format: <name> (Attribute/Association Override) - StringBuilder sb = new StringBuilder(); - sb.append(name); - sb.append(" ("); - sb.append(overrideType); - sb.append(") "); - return sb.toString(); - } - - protected ILabelProvider buildOverrideLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - return buildOverrideDisplayString((ReadOnlyOverride) element); - } - }; - } - - protected Adapter buildOverridesAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - //no way to add/remove/edit overrides, they are all defaulted in - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - //no way to add/remove/edit overrides, they are all defaulted in - } - }; - } - - protected ListValueModel<ReadOnlyOverride> buildOverridesListHolder() { - PropertyValueModel<AttributeOverrideContainer> attributeOverrideContainerHolder = buildAttributeOverrideContainerHolder(); - List<ListValueModel<? extends ReadOnlyOverride>> list = new ArrayList<ListValueModel<? extends ReadOnlyOverride>>(); - - list.add(buildSpecifiedAttributeOverridesListHolder(attributeOverrideContainerHolder)); - list.add(buildDefaultAttributeOverridesListHolder(attributeOverrideContainerHolder)); - - if (supportsAssociationOverrides()) { - PropertyValueModel<AssociationOverrideContainer> associationOverrideContainerHolder = buildAssociationOverrideContainerHolder(); - list.add(buildSpecifiedAssociationOverridesListHolder(associationOverrideContainerHolder)); - list.add(buildDefaultAssociationOverridesListHolder(associationOverrideContainerHolder)); - } - - return new CompositeListValueModel<ListValueModel<? extends ReadOnlyOverride>, ReadOnlyOverride>(list); - } - - protected abstract PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder(); - - protected abstract PropertyValueModel<AssociationOverrideContainer> buildAssociationOverrideContainerHolder(); - - private ListValueModel<ReadOnlyOverride> buildOverridesListModel() { - return new ItemPropertyListValueModelAdapter<ReadOnlyOverride>( - buildOverridesListHolder(), - ReadOnlyOverride.NAME_PROPERTY); - } - - private Transformer<ReadOnlyOverride, Control> buildPaneTransformer() { - return new Transformer<ReadOnlyOverride, Control>() { - public Control transform(ReadOnlyOverride override) { - return AbstractOverridesComposite.this.transformSelectedOverride(override); - } - }; - } - - /** - * Given the selected override, return the control that will be displayed - */ - protected Control transformSelectedOverride(ReadOnlyOverride selectedOverride) { - if (selectedOverride instanceof ReadOnlyAttributeOverride) { - return AbstractOverridesComposite.this.attributeOverridePane.getControl(); - } - - if (selectedOverride instanceof ReadOnlyAssociationOverride) { - return AbstractOverridesComposite.this.associationOverridePane.getControl(); - } - - return null; - } - - private ListValueModel<AssociationOverride> buildSpecifiedAssociationOverridesListHolder(PropertyValueModel<AssociationOverrideContainer> containerHolder) { - return new ListAspectAdapter<AssociationOverrideContainer, AssociationOverride>(containerHolder, OverrideContainer.SPECIFIED_OVERRIDES_LIST) { - @Override - protected ListIterator<AssociationOverride> listIterator_() { - return new SuperListIteratorWrapper<AssociationOverride>(this.subject.specifiedOverrides()); - } - - @Override - protected int size_() { - return this.subject.specifiedOverridesSize(); - } - }; - } - - private ListValueModel<AttributeOverride> buildSpecifiedAttributeOverridesListHolder(PropertyValueModel<AttributeOverrideContainer> containerHolder) { - return new ListAspectAdapter<AttributeOverrideContainer, AttributeOverride>(containerHolder, OverrideContainer.SPECIFIED_OVERRIDES_LIST) { - @Override - protected ListIterator<AttributeOverride> listIterator_() { - return new SuperListIteratorWrapper<AttributeOverride>(this.subject.specifiedOverrides()); - } - - @Override - protected int size_() { - return this.subject.specifiedOverridesSize(); - } - }; - } - - void updateOverride(boolean convertToSpecified) { - if (isPopulating()) { - return; - } - - setPopulating(true); - - try { - ReadOnlyOverride override = this.selectedOverrideHolder.getValue(); - - ReadOnlyOverride newOverride = convertToSpecified ? - ((VirtualOverride) override).convertToSpecified() : - ((Override_) override).convertToVirtual(); - this.selectedOverrideHolder.setValue(newOverride); - } - finally { - setPopulating(false); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java deleted file mode 100644 index b512da1b75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java +++ /dev/null @@ -1,344 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.AbstractAdapter; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Join Columns ---------------------------------------------------------- | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | AddRemoveListPane | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * - * @version 2.0 - * @since 2.0 - */ -public abstract class AbstractPrimaryKeyJoinColumnsComposite<T extends Entity> extends Pane<T> -{ - protected WritablePropertyValueModel<PrimaryKeyJoinColumn> joinColumnHolder; - - public AbstractPrimaryKeyJoinColumnsComposite(Pane<? extends T> subjectHolder, - Composite parent) { - - super(subjectHolder, parent, false); - } - - void addJoinColumn(PrimaryKeyJoinColumnStateObject stateObject) { - PrimaryKeyJoinColumn joinColumn = getSubject().addSpecifiedPrimaryKeyJoinColumn(); - stateObject.updateJoinColumn(joinColumn); - } - - void addPrimaryKeyJoinColumn() { - - PrimaryKeyJoinColumnDialog dialog = new PrimaryKeyJoinColumnDialog( - getShell(), - getSubject(), - null - ); - - dialog.openDialog(buildAddPrimaryKeyJoinColumnPostExecution()); - } - - private PostExecution<PrimaryKeyJoinColumnDialog> buildAddPrimaryKeyJoinColumnPostExecution() { - return new PostExecution<PrimaryKeyJoinColumnDialog>() { - public void execute(PrimaryKeyJoinColumnDialog dialog) { - if (dialog.wasConfirmed()) { - addJoinColumn(dialog.getSubject()); - } - } - }; - } - - protected abstract ListValueModel<? extends ReadOnlyPrimaryKeyJoinColumn> buildDefaultJoinColumnsListHolder(); - - private PostExecution<PrimaryKeyJoinColumnDialog> buildEditPrimaryKeyJoinColumnPostExecution() { - return new PostExecution<PrimaryKeyJoinColumnDialog>() { - public void execute(PrimaryKeyJoinColumnDialog dialog) { - if (dialog.wasConfirmed()) { - editJoinColumn(dialog.getSubject()); - } - } - }; - } - - private WritablePropertyValueModel<PrimaryKeyJoinColumn> buildJoinColumnHolder() { - return new SimplePropertyValueModel<PrimaryKeyJoinColumn>(); - } - - String buildJoinColumnLabel(ReadOnlyPrimaryKeyJoinColumn joinColumn) { - if (joinColumn.isDefault()) { - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - if (joinColumn.getSpecifiedName() == null) { - if (joinColumn.getSpecifiedReferencedColumnName() == null) { - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsBothDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsFirstDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - if (joinColumn.getSpecifiedReferencedColumnName() == null) { - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsSecDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParams, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - private Adapter buildJoinColumnsAdapter() { - return new AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addPrimaryKeyJoinColumn(); - } - - @Override - public boolean hasOptionalButton() { - return true; - } - - @Override - public String optionalButtonText() { - return JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_edit; - } - - @Override - public void optionOnSelection(ObjectListSelectionModel listSelectionModel) { - editPrimaryKeyJoinColumn(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - - int[] selectedIndices = listSelectionModel.selectedIndices(); - Entity entity = getSubject(); - - for (int index = selectedIndices.length; --index >= 0; ) { - entity.removeSpecifiedPrimaryKeyJoinColumn(selectedIndices[index]); - } - } - }; - } - - private ILabelProvider buildJoinColumnsListLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - return buildJoinColumnLabel((ReadOnlyPrimaryKeyJoinColumn) element); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - private ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListHolder() { - List<ListValueModel<? extends ReadOnlyPrimaryKeyJoinColumn>> list = new ArrayList<ListValueModel<? extends ReadOnlyPrimaryKeyJoinColumn>>(); - list.add(buildSpecifiedJoinColumnsListHolder()); - list.add(buildDefaultJoinColumnsListHolder()); - return new CompositeListValueModel<ListValueModel<? extends ReadOnlyPrimaryKeyJoinColumn>, ReadOnlyPrimaryKeyJoinColumn>(list); - } - - private ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListModel() { - return new ItemPropertyListValueModelAdapter<ReadOnlyPrimaryKeyJoinColumn>( - buildPrimaryKeyJoinColumnsListHolder(), - ReadOnlyNamedColumn.SPECIFIED_NAME_PROPERTY, - ReadOnlyNamedColumn.DEFAULT_NAME_PROPERTY, - ReadOnlyBaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, - ReadOnlyBaseJoinColumn.DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY - ); - } - - ListValueModel<PrimaryKeyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<Entity, PrimaryKeyJoinColumn>(getSubjectHolder(), Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST) { - @Override - @SuppressWarnings("unchecked") - protected ListIterator<PrimaryKeyJoinColumn> listIterator_() { - return (ListIterator<PrimaryKeyJoinColumn>) subject.specifiedPrimaryKeyJoinColumns(); - } - - @Override - protected int size_() { - return subject.specifiedPrimaryKeyJoinColumnsSize(); - } - }; - } - - void editJoinColumn(PrimaryKeyJoinColumnStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - void editPrimaryKeyJoinColumn(ObjectListSelectionModel listSelectionModel) { - - PrimaryKeyJoinColumn joinColumn = (PrimaryKeyJoinColumn) listSelectionModel.selectedValue(); - - PrimaryKeyJoinColumnDialog dialog = new PrimaryKeyJoinColumnDialog( - getShell(), - getSubject(), - joinColumn - ); - - dialog.openDialog(buildEditPrimaryKeyJoinColumnPostExecution()); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initialize() { - super.initialize(); - joinColumnHolder = buildJoinColumnHolder(); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Primary Key Join Columns group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn - ); - - // Override Default Join Columns check box - addCheckBox( - addSubPane(groupPane, 8), - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns, - buildOverrideDefaultJoinColumnHolder(), - null - ); - - // Primary Key Join Columns list pane - AddRemoveListPane<Entity> joinColumnsListPane = new AddRemoveListPane<Entity>( - this, - groupPane, - buildJoinColumnsAdapter(), - buildPrimaryKeyJoinColumnsListModel(), - joinColumnHolder, - buildJoinColumnsListLabelProvider(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS - ); - - installJoinColumnsListPaneEnabler(joinColumnsListPane); - } - - private void installJoinColumnsListPaneEnabler(AddRemoveListPane<Entity> pane) { - new PaneEnabler( - buildOverrideDefaultJoinColumnHolder(), - pane - ); - } - - void updateJoinColumns(boolean selected) { - - if (isPopulating()) { - return; - } - - setPopulating(true); - - try { - // Add a join column by creating a specified one using the default - // one if it exists - if (selected) { - - switchDefaultToSpecified(); - } - // Remove all the specified join columns - else { - for (int index = getSubject().specifiedPrimaryKeyJoinColumnsSize(); --index >= 0; ) { - getSubject().removeSpecifiedPrimaryKeyJoinColumn(index); - } - } - } - finally { - setPopulating(false); - } - } - - protected abstract void switchDefaultToSpecified(); - - private class OverrideDefaultJoinColumnHolder extends ListPropertyValueModelAdapter<Boolean> - implements WritablePropertyValueModel<Boolean> { - - public OverrideDefaultJoinColumnHolder() { - super(buildSpecifiedJoinColumnsListHolder()); - } - - @Override - protected Boolean buildValue() { - return listHolder.size() > 0; - } - - public void setValue(Boolean value) { - updateJoinColumns(value.booleanValue()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractSecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractSecondaryTablesComposite.java deleted file mode 100644 index 88748b18b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractSecondaryTablesComposite.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PrimaryKeyJoinColumnsInSecondaryTableComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OrmEntity - * @see OrmEntityComposite - The container of this pane - * @see AddRemoveListPane - * @see PrimaryKeyJoinColumnsInSecondaryTableComposite - * - * @version 2.0 - * @since 1.0 - */ -public abstract class AbstractSecondaryTablesComposite<T extends Entity> extends Pane<T> -{ - /** - * Creates a new <code>SecondaryTablesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public AbstractSecondaryTablesComposite(Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - /** - * Creates a new <code>SecondaryTablesComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public AbstractSecondaryTablesComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - protected void addSecondaryTableFromDialog(SecondaryTableDialog dialog, ObjectListSelectionModel listSelectionModel) { - if (dialog.open() != Window.OK) { - return; - } - - SecondaryTable secondaryTable = this.getSubject().addSpecifiedSecondaryTable(); - secondaryTable.setSpecifiedName(dialog.getSelectedTable()); - secondaryTable.setSpecifiedCatalog(dialog.getSelectedCatalog()); - secondaryTable.setSpecifiedSchema(dialog.getSelectedSchema()); - - listSelectionModel.setSelectedValue(secondaryTable); - } - - protected WritablePropertyValueModel<SecondaryTable> buildSecondaryTableHolder() { - return new SimplePropertyValueModel<SecondaryTable>(); - } - - protected ILabelProvider buildSecondaryTableLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - // TODO display a qualified name instead - SecondaryTable secondaryTable = (SecondaryTable) element; - if (secondaryTable.getName() != null) { - return secondaryTable.getName(); - } - return "";//TODO - } - }; - } - - protected SecondaryTableDialog buildSecondaryTableDialogForAdd() { - return new SecondaryTableDialog(getShell(), getSubject().getJpaProject(), getSubject().getTable().getDefaultCatalog(), getSubject().getTable().getDefaultSchema()); - } - - protected AddRemoveListPane.Adapter buildSecondaryTablesAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - SecondaryTableDialog dialog = buildSecondaryTableDialogForAdd(); - addSecondaryTableFromDialog(dialog, listSelectionModel); - } - - @Override - public boolean hasOptionalButton() { - return true; - } - - @Override - public String optionalButtonText() { - return JptUiDetailsMessages.SecondaryTablesComposite_edit; - } - - @Override - public void optionOnSelection(ObjectListSelectionModel listSelectionModel) { - SecondaryTable secondaryTable = (SecondaryTable) listSelectionModel.selectedValue(); - SecondaryTableDialog dialog = new SecondaryTableDialog(getShell(), getSubject().getJpaProject(), secondaryTable); - editSecondaryTableFromDialog(dialog, secondaryTable); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - Entity entity = getSubject(); - int[] selectedIndices = listSelectionModel.selectedIndices(); - - for (int index = selectedIndices.length; --index >= 0; ) { - entity.removeSpecifiedSecondaryTable(selectedIndices[index]); - } - } - - @Override - public boolean enableOptionOnSelectionChange(ObjectListSelectionModel listSelectionModel) { - if (listSelectionModel.selectedValuesSize() != 1) { - return false; - } - SecondaryTable secondaryTable = (SecondaryTable) listSelectionModel.selectedValue(); - return !secondaryTable.isVirtual(); - } - - @Override - public boolean enableRemoveOnSelectionChange(ObjectListSelectionModel listSelectionModel) { - if (listSelectionModel.selectedValue() == null) { - return false; - } - SecondaryTable secondaryTable = (SecondaryTable) listSelectionModel.selectedValue(); - return !secondaryTable.isVirtual(); - } - }; - } - - protected void editSecondaryTableFromDialog(SecondaryTableDialog dialog, SecondaryTable secondaryTable) { - if (dialog.open() != Window.OK) { - return; - } - - secondaryTable.setSpecifiedName(dialog.getSelectedTable()); - secondaryTable.setSpecifiedCatalog(dialog.getSelectedCatalog()); - secondaryTable.setSpecifiedSchema(dialog.getSelectedSchema()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractTransientMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractTransientMappingUiDefinition.java deleted file mode 100644 index 0453e01eb0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractTransientMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.TransientMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractTransientMappingUiDefinition<M, T extends TransientMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractTransientMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.TransientMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.TransientMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractVersionMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractVersionMappingComposite.java deleted file mode 100644 index b53788f97d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractVersionMappingComposite.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Column; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.ConvertibleMapping; -import org.eclipse.jpt.jpa.core.context.TemporalConverter; -import org.eclipse.jpt.jpa.core.context.VersionMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see VersionMapping - * @see ColumnComposite - * @see TemporalTypeComposite - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractVersionMappingComposite<T extends VersionMapping> - extends Pane<T> - implements JpaComposite -{ - /** - * Creates a new <code>VersionMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IVersionMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractVersionMappingComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeVersionCollapsibleSection(container); - initializeTypeCollapsibleSection(container); - } - - protected void initializeVersionCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.VersionSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeVersionSection(container); - } - - protected abstract void initializeVersionSection(Composite container); - - protected void initializeTypeCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages.TypeSection_type - ); - this.initializeTypeSection(container); - } - - protected void initializeTypeSection(Composite container) { - ((GridLayout) container.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_default, - buildConverterBooleanHolder(null), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - PropertyValueModel<Converter> converterHolder = buildConverterHolder(); - // Temporal - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_temporal, - buildConverterBooleanHolder(TemporalConverter.class), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(converterHolder), container, getWidgetFactory())); - } - - protected PropertyValueModel<Column> buildColumnHolder() { - return new TransformationPropertyValueModel<T, Column>(getSubjectHolder()) { - @Override - protected Column transform_(T value) { - return value.getColumn(); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildConverterBooleanHolder(final Class<? extends Converter> converterType) { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getConverter(); - return Boolean.valueOf(converter.getType() == converterType); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(converterType); - } - } - }; - } - - private PropertyValueModel<Converter> buildConverterHolder() { - return new PropertyAspectAdapter<VersionMapping, Converter>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getConverter(); - } - }; - } - - private PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return converter.getType() == TemporalConverter.class ? (TemporalConverter) converter : null; - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractVersionMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractVersionMappingUiDefinition.java deleted file mode 100644 index 829f66bc5b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractVersionMappingUiDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.VersionMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractVersionMappingUiDefinition<M, T extends VersionMapping> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractVersionMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.VersionMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages.VersionMappingUiProvider_linkLabel; - } - - public String getKey() { - return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AccessTypeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AccessTypeComposite.java deleted file mode 100644 index 0225750f26..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AccessTypeComposite.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------ | - * | Access Type: | |v| | - * | ------------------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see AccessHolder - * @see OrmEntityComposite - A container of this pane - * @see OrmEmbeddableComposite - A container of this pane - * @see OrmMappedSuperclassComposite - A container of this pane - * - * @version 2.2 - * @since 1.0 - */ -public class AccessTypeComposite extends Pane<AccessHolder> { - - /** - * Creates a new <code>AccessTypeComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public AccessTypeComposite(Pane<?> parentPane, - PropertyValueModel<? extends AccessHolder> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - public AccessTypeComposite(Pane<?> parentPane, - PropertyValueModel<? extends AccessHolder> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets); - } - - @Override - protected void initializeLayout(Composite container) { - - EnumFormComboViewer<AccessHolder, AccessType> comboViewer = - addAccessTypeComboViewer(container); - - addLabeledComposite( - container, - JptUiMessages.AccessTypeComposite_access, - comboViewer.getControl() - ); - } - - private EnumFormComboViewer<AccessHolder, AccessType> addAccessTypeComboViewer(Composite container) { - - return new EnumFormComboViewer<AccessHolder, AccessType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(AccessHolder.DEFAULT_ACCESS_PROPERTY); - propertyNames.add(AccessHolder.SPECIFIED_ACCESS_PROPERTY); - } - - @Override - protected AccessType[] getChoices() { - return AccessType.values(); - } - - @Override - protected AccessType getDefaultValue() { - return getSubject().getDefaultAccess(); - } - - @Override - protected String displayString(AccessType value) { - return buildDisplayString( - JptUiMessages.class, - AccessTypeComposite.this, - value - ); - } - - @Override - protected AccessType getValue() { - return getSubject().getSpecifiedAccess(); - } - - @Override - protected void setValue(AccessType value) { - getSubject().setSpecifiedAccess(value); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AddQueryDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AddQueryDialog.java deleted file mode 100644 index 60204adef6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AddQueryDialog.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.common.ui.internal.widgets.ValidatingDialog; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticListValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Clients can use this dialog to prompt the user for SecondaryTable settings. - * Use the following once the dialog is closed: - * @see #getSelectedTable() - * @see #getSelectedCatalog() - * @see #getSelectedSchema() - * @version 2.1 - * @since 2.1 - */ -public class AddQueryDialog extends ValidatingDialog<AddQueryStateObject> { - public static final String NAMED_QUERY = "namedQuery"; //$NON-NLS-1$ - public static final String NAMED_NATIVE_QUERY = "namedNativeQuery"; //$NON-NLS-1$ - - /** - * The associated persistence unit - */ - private PersistenceUnit pUnit; - - // ********** constructors ********** - - /** - * Use this constructor to edit an existing conversion value - * @param pUnit - */ - public AddQueryDialog(Shell parent, PersistenceUnit pUnit) { - super(parent); - this.pUnit = pUnit; - } - - @Override - protected AddQueryStateObject buildStateObject() { - return new AddQueryStateObject(this.pUnit); - } - - // ********** open ********** - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(this.getTitle()); - } - - @Override - protected String getTitle() { - return JptUiDetailsMessages.AddQueryDialog_title; - } - - @Override - protected String getDescriptionTitle() { - return JptUiDetailsMessages.AddQueryDialog_descriptionTitle; - } - - @Override - protected String getDescription() { - return JptUiDetailsMessages.AddQueryDialog_description; - } - - @Override - protected DialogPane<AddQueryStateObject> buildLayout(Composite container) { - return new QueryDialogPane(container); - } - - @Override - public void create() { - super.create(); - - QueryDialogPane pane = (QueryDialogPane) getPane(); - pane.selectAll(); - - getButton(OK).setEnabled(false); - } - - - // ********** public API ********** - - /** - * Return the data value set in the text widget. - */ - public String getName() { - return getSubject().getName(); - } - - /** - * Return the object value set in the text widget. - */ - public String getQueryType() { - return getSubject().getQueryType(); - } - - private class QueryDialogPane extends DialogPane<AddQueryStateObject> { - - private Text nameText; - - QueryDialogPane(Composite parent) { - super(AddQueryDialog.this.getSubjectHolder(), parent); - } - - @Override - protected void initializeLayout(Composite container) { - this.nameText = addLabeledText( - container, - JptUiDetailsMessages.AddQueryDialog_name, - buildNameHolder() - ); - - addLabeledCombo( - container, - JptUiDetailsMessages.AddQueryDialog_queryType, - buildQueryTypeListHolder(), - buildQueryTypeHolder(), - buildStringConverter(), - null); - } - - protected ListValueModel<String> buildQueryTypeListHolder() { - List<String> queryTypes = new ArrayList<String>(); - queryTypes.add(NAMED_QUERY); - queryTypes.add(NAMED_NATIVE_QUERY); - - return new StaticListValueModel<String>(queryTypes); - } - - private StringConverter<String> buildStringConverter() { - return new StringConverter<String>() { - public String convertToString(String value) { - if (value == NAMED_QUERY) { - return JptUiDetailsMessages.AddQueryDialog_namedQuery; - } - if (value == NAMED_NATIVE_QUERY) { - return JptUiDetailsMessages.AddQueryDialog_namedNativeQuery; - } - return value; - } - }; - } - - private WritablePropertyValueModel<String> buildNameHolder() { - return new PropertyAspectAdapter<AddQueryStateObject, String>(getSubjectHolder(), AddQueryStateObject.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getName(); - } - - @Override - protected void setValue_(String value) { - this.subject.setName(value); - } - }; - } - - private WritablePropertyValueModel<String> buildQueryTypeHolder() { - return new PropertyAspectAdapter<AddQueryStateObject, String>(getSubjectHolder(), AddQueryStateObject.QUERY_TYPE_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getQueryType(); - } - - @Override - protected void setValue_(String value) { - this.subject.setQueryType(value); - } - }; - } - - void selectAll() { - this.nameText.selectAll(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AddQueryStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AddQueryStateObject.java deleted file mode 100644 index 835dcb7ec8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AddQueryStateObject.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.node.AbstractNode; -import org.eclipse.jpt.common.utility.internal.node.Node; -import org.eclipse.jpt.common.utility.internal.node.Problem; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; - -/** - * This is the state object used by the <code>AddQueryDialog</code>, which stores - * the current name and validates it when it is modified. - * - * @see AddQueryDialog - * - * @version 2.1 - * @since 2.1 - */ -final class AddQueryStateObject extends AbstractNode -{ - /** - * The initial name or <code>null</code> - */ - private String name; - - /** - * The initial queryType or <code>null</code> - */ - private String queryType; - - /** - * The <code>Validator</code> used to validate this state object. - */ - private Validator validator; - - /** - * The associated persistence unit - */ - private PersistenceUnit pUnit; - - /** - * Notifies a change in the data value property. - */ - static final String NAME_PROPERTY = "nameProperty"; //$NON-NLS-1$ - - /** - * Notifies a change in the query type property. - */ - static final String QUERY_TYPE_PROPERTY = "queryTypeProperty"; //$NON-NLS-1$ - - /** - * Creates a new <code>NewNameStateObject</code>. - * - * @param name The initial input or <code>null</code> if no initial value can - * be specified - * @param names The collection of names that can't be used or an empty - * collection if none are available - */ - AddQueryStateObject(PersistenceUnit pUnit) { - super(null); - this.pUnit = pUnit; - } - - private void addNameProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.name)) { - currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_nameMustBeSpecified, IMessageProvider.ERROR)); - } - else if (names().contains(this.name)){ - currentProblems.add(buildProblem(JptUiDetailsMessages.AddQueryDialog_nameExists, IMessageProvider.WARNING)); - } - } - - private void addQueryTypeProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.queryType)) { - currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_typeMustBeSpecified, IMessageProvider.ERROR)); - } - } - - @Override - protected void addProblemsTo(List<Problem> currentProblems) { - super.addProblemsTo(currentProblems); - addNameProblemsTo(currentProblems); - addQueryTypeProblemsTo(currentProblems); - } - - private List<String> names(){ - List<String> names = new ArrayList<String>(); - for (Iterator<Query> queries = this.pUnit.queries(); queries.hasNext();){ - String name = queries.next().getName(); - names.add(name); - } - return names; - } - - @Override - protected void checkParent(Node parentNode) { - //no parent - } - - public String displayString() { - return null; - } - - String getName() { - return this.name; - } - - String getQueryType() { - return this.queryType; - } - - public void setName(String newName) { - String oldName = this.name; - this.name = newName; - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public void setQueryType(String newQueryType) { - String old = this.queryType; - this.queryType = newQueryType; - firePropertyChanged(QUERY_TYPE_PROPERTY, old, newQueryType); - } - - @Override - public void setValidator(Validator validator) { - this.validator = validator; - } - - @Override - public Validator getValidator() { - return this.validator; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AssociationOverrideComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AssociationOverrideComposite.java deleted file mode 100644 index 664a6e29e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AssociationOverrideComposite.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | JoinColumnsComposite | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see AssociationOverride - * @see EntityOverridesComposite - The parent container - * @see JoinColumnJoiningStrategyPane - * - * @version 2.2 - * @since 1.0 - */ -public class AssociationOverrideComposite - extends Pane<ReadOnlyAssociationOverride> -{ - /** - * Creates a new <code>AssociationOverrideComposite</code>. - * - * @param subjectHolder The holder of the subject <code>AssociationOverride</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public AssociationOverrideComposite(Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyAssociationOverride> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title); - - addJoinColumnJoiningStrategyPane(composite); - - addSubPane(composite, 5); - } - - protected void addJoinColumnJoiningStrategyPane(Composite container) { - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithoutIncludeOverrideCheckBox( - this, - buildRelationshipModel(), - container); - } - - private PropertyValueModel<ReadOnlyJoinColumnRelationship> buildRelationshipModel() { - return new TransformationPropertyValueModel<ReadOnlyAssociationOverride, ReadOnlyJoinColumnRelationship>(getSubjectHolder()) { - @Override - protected ReadOnlyJoinColumnRelationship transform_(ReadOnlyAssociationOverride value) { - // with virtual overrides: m:m mappings do not support join columns, so we need to check - ReadOnlyRelationship relationship = value.getRelationship(); - return (relationship instanceof ReadOnlyJoinColumnRelationship) ? - (ReadOnlyJoinColumnRelationship) relationship : null; - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AttributeOverrideComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AttributeOverrideComposite.java deleted file mode 100644 index fb29087959..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AttributeOverrideComposite.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | ColumnComposite | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see AttributeOverride - * @see EntityOverridesComposite - The parent container - * @see ColumnComposite - * - * @version 2.0 - * @since 1.0 - */ -public class AttributeOverrideComposite extends Pane<ReadOnlyAttributeOverride> -{ - - /** - * Creates a new <code>AttributeOverrideComposite</code>. - * - * @param subjectHolder The holder of the subject <code>AttributeOverride</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public AttributeOverrideComposite(Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyAttributeOverride> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - new ColumnComposite( - this, - buildColumnHolder(), - container, - false - ); - } - - private PropertyValueModel<ReadOnlyColumn> buildColumnHolder() { - return new TransformationPropertyValueModel<ReadOnlyAttributeOverride, ReadOnlyColumn>(getSubjectHolder()) { - @Override - protected ReadOnlyColumn transform_(ReadOnlyAttributeOverride value) { - return value.getColumn(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnDialog.java deleted file mode 100644 index 25ca0bd349..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnDialog.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.ValidatingDialog; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.swt.widgets.Shell; - -/** - * The abstract definition the dialog showing the information for a join column - * to edit or to create. - * - * @see BaseJoinColumnStateObject - * - * @version 2.0 - * @since 1.0 - */ -public abstract class BaseJoinColumnDialog<T extends BaseJoinColumnStateObject> - extends ValidatingDialog<T> -{ - - /** - * Either the join column to edit or <code>null</code> if this state object - * is used to create a new one. - */ - private ReadOnlyBaseJoinColumn joinColumn; - - /** - * The owner of the join column to create or where it is located. - */ - private Object owner; - - /** - * Creates a new <code>BaseJoinColumnDialog</code>. - * - * @param parent The parent shell - * @param owner The owner of the join column to create or where it is located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public BaseJoinColumnDialog(Shell parent, - Object owner, - ReadOnlyBaseJoinColumn joinColumn) { - - super(parent); - - this.owner = owner; - this.joinColumn = joinColumn; - } - - /* - * (non-Javadoc) - */ - @Override - protected String getDescription() { - return JptUiDetailsMessages.JoinColumnDialog_description; - } - - /* - * (non-Javadoc) - */ - @Override - protected String getDescriptionTitle() { - - if (joinColumn == null) { - return JptUiDetailsMessages.JoinColumnDialog_addJoinColumnDescriptionTitle; - } - - return JptUiDetailsMessages.JoinColumnDialog_editJoinColumnDescriptionTitle; - } - - /** - * Returns the join column used by this state object for editing or - * <code>null</code> if this state object is used to create a new one. - * - * @return Either the edited join column or <code>null</code> - */ - public ReadOnlyBaseJoinColumn getJoinColumn() { - return joinColumn; - } - - /** - * Returns the owner where the join column is located or where a new one can - * be added. - * - * @return The parent of the join column - */ - protected Object getOwner() { - return owner; - } - - /* - * (non-Javadoc) - */ - @Override - protected String getTitle() { - - if (joinColumn == null) { - return JptUiDetailsMessages.JoinColumnDialog_addJoinColumnTitle; - } - - return JptUiDetailsMessages.JoinColumnDialog_editJoinColumnTitle; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnDialogPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnDialogPane.java deleted file mode 100644 index 92dc42d6a3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnDialogPane.java +++ /dev/null @@ -1,442 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------- | - * | Name: | I |v| | - * | ------------------------------------------------- | - * | ------------------------------------------------- | - * | Referenced Column Name: | I |v| | - * | ------------------------------------------------- | - * | ------------------------------------------------- | - * | Table: | I |v| | - * | ------------------------------------------------- | - * | ------------------------------------------------- | - * | Column Definition: | I | | - * | ------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see BaseJoinColumnStateObject - * @see InverseJoinColumnInJoinTableDialog - A container of this pane - * @see JoinColumnInReferenceTableDialog - A container of this pane - * @see PrimaryKeyJoinColumnDialog - A container of this pane - * @see PrimaryKeyJoinColumnInSecondaryTableDialog - A container of this pane - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class BaseJoinColumnDialogPane<T extends BaseJoinColumnStateObject> extends DialogPane<T> -{ - /** - * A key used to represent the default value, this is required to convert - * the selected item from a combo to <code>null</code>. This key is most - * likely never typed the user and it will help to convert the value to - * <code>null</code> when it's time to set the new selected value into the - * model. - */ - protected static String DEFAULT_KEY = "?!#!?#?#?default?#?!#?!#?"; - - /** - * Creates a new <code>BaseJoinColumnDialogPane</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public BaseJoinColumnDialogPane(PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(subjectHolder, parent); - } - - private WritablePropertyValueModel<String> buildColumnDefinitionHolder() { - return new PropertyAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), BaseJoinColumnStateObject.COLUMN_DEFINITION_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getColumnDefinition(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - subject.setColumnDefinition(value); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected Composite addContainer(Composite parent) { - return addSubPane(parent, 0, 7, 0, 5); - } - - private PropertyValueModel<String> buildDefaultNameHolder() { - return new TransformationPropertyValueModel<BaseJoinColumnStateObject, String>(getSubjectHolder()) { - @Override - protected String transform_(BaseJoinColumnStateObject value) { - String name = value.getDefaultName(); - - if (name == null) { - name = DEFAULT_KEY; - } - else { - name = DEFAULT_KEY + name; - } - - return name; - } - }; - } - - private ListValueModel<String> buildDefaultNameListHolder() { - return new PropertyListValueModelAdapter<String>( - buildDefaultNameHolder() - ); - } - - private PropertyValueModel<String> buildDefaultReferencedColumnNameHolder() { - return new TransformationPropertyValueModel<BaseJoinColumnStateObject, String>(getSubjectHolder()) { - @Override - protected String transform_(BaseJoinColumnStateObject value) { - String name = value.getDefaultReferencedColumnName(); - - if (name == null) { - name = DEFAULT_KEY; - } - else { - name = DEFAULT_KEY + name; - } - - return name; - } - }; - } - - private ListValueModel<String> buildDefaultReferencedColumnNameListHolder() { - return new PropertyListValueModelAdapter<String>( - buildDefaultReferencedColumnNameHolder() - ); - } - - private PropertyValueModel<String> buildDefaultTableHolder() { - return new TransformationPropertyValueModel<BaseJoinColumnStateObject, String>(getSubjectHolder()) { - @Override - protected String transform_(BaseJoinColumnStateObject value) { - String name = value.getDefaultTable(); - - if (name == null) { - name = DEFAULT_KEY; - } - else { - name = DEFAULT_KEY + name; - } - - return name; - } - }; - } - - private ListValueModel<String> buildDefaultTableListHolder() { - return new PropertyListValueModelAdapter<String>( - buildDefaultTableHolder() - ); - } - - private StringConverter<String> buildDisplayableStringConverter(final DefaultValueHandler handler) { - return new StringConverter<String>() { - public String convertToString(String value) { - - if (getSubject() == null) { - return null; - } - - if (value == null) { - value = handler.getDefaultValue(); - - if (value != null) { - value = DEFAULT_KEY + value; - } - else { - value = DEFAULT_KEY; - } - } - - if (value.startsWith(DEFAULT_KEY)) { - String defaultName = value.substring(DEFAULT_KEY.length()); - - if (defaultName.length() > 0) { - value = NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - defaultName - ); - } - else { - value = JptCommonUiMessages.DefaultEmpty; - } - } - - return value; - } - }; - } - - private WritablePropertyValueModel<String> buildNameHolder() { - return new PropertyAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), BaseJoinColumnStateObject.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getName(); - } - - @Override - protected void setValue_(String value) { - - // Convert the default value or an empty string to null - if ((value != null) && - ((value.length() == 0) || value.startsWith(DEFAULT_KEY))) { - - value = null; - } - - subject.setName(value); - } - }; - } - - private ListValueModel<String> buildNameListHolder() { - return new ListAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), BaseJoinColumnStateObject.NAMES_LIST) { - @Override - protected ListIterator<String> listIterator_() { - return subject.names(); - } - @Override - protected int size_() { - return subject.columnsSize(); - } - }; - } - - private ListValueModel<String> buildNamesListHolder() { - ArrayList<ListValueModel<String>> holders = new ArrayList<ListValueModel<String>>(2); - holders.add(buildDefaultNameListHolder()); - holders.add(buildNameListHolder()); - return new CompositeListValueModel<ListValueModel<String>, String>(holders); - } - - private StringConverter<String> buildNameStringConverter() { - return buildDisplayableStringConverter(new DefaultValueHandler() { - public String getDefaultValue() { - return getSubject().getDefaultName(); - } - }); - } - - private WritablePropertyValueModel<String> buildReferencedColumnNameHolder() { - return new PropertyAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), BaseJoinColumnStateObject.REFERENCED_COLUMN_NAME_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getReferencedColumnName(); - } - - @Override - protected void setValue_(String value) { - - // Convert the default value or an empty string to null - if ((value != null) && - ((value.length() == 0) || value.startsWith(DEFAULT_KEY))) { - - value = null; - } - - subject.setReferencedColumnName(value); - } - }; - } - - private ListValueModel<String> buildReferencedColumnNameListHolder() { - return new ListAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), BaseJoinColumnStateObject.REFERENCE_COLUMN_NAMES_LIST) { - @Override - protected ListIterator<String> listIterator_() { - return subject.referenceColumnNames(); - } - @Override - protected int size_() { - return subject.referenceColumnsSize(); - } - }; - } - - private ListValueModel<String> buildReferencedColumnNamesListHolder() { - ArrayList<ListValueModel<String>> holders = new ArrayList<ListValueModel<String>>(2); - holders.add(buildDefaultReferencedColumnNameListHolder()); - holders.add(buildReferencedColumnNameListHolder()); - return new CompositeListValueModel<ListValueModel<String>, String>(holders); - } - - private StringConverter<String> buildReferencedColumnNameStringConverter() { - return buildDisplayableStringConverter(new DefaultValueHandler() { - public String getDefaultValue() { - return getSubject().getDefaultReferencedColumnName(); - } - }); - } - - private WritablePropertyValueModel<String> buildTableHolder() { - return new PropertyAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), BaseJoinColumnStateObject.TABLE_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getTable(); - } - - @Override - protected void setValue_(String value) { - - // Convert the default value or an empty string to null - if ((value != null) && - ((value.length() == 0) || value.startsWith(DEFAULT_KEY))) { - - value = null; - } - - subject.setTable(value); - } - }; - } - - private ListValueModel<String> buildTableListHolder() { - return new ListAspectAdapter<BaseJoinColumnStateObject, String>(getSubjectHolder(), "") { - @Override - protected ListIterator<String> listIterator_() { - return subject.tables(); - } - }; - } - - private ListValueModel<String> buildTablesListHolder() { - ArrayList<ListValueModel<String>> holders = new ArrayList<ListValueModel<String>>(2); - holders.add(buildDefaultTableListHolder()); - holders.add(buildTableListHolder()); - return new CompositeListValueModel<ListValueModel<String>, String>(holders); - } - - private StringConverter<String> buildTableStringConverter() { - return buildDisplayableStringConverter(new DefaultValueHandler() { - public String getDefaultValue() { - return getSubject().getDefaultTable(); - } - }); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Name widgets - Combo nameCombo = addLabeledEditableCombo( - container, - JptUiDetailsMessages.JoinColumnDialog_name, - buildNamesListHolder(), - buildNameHolder(), - buildNameStringConverter(), - JpaHelpContextIds.MAPPING_JOIN_COLUMN_NAME - ); - - SWTUtil.attachDefaultValueHandler(nameCombo); - - // Referenced Column Name widgets - Combo referencedColumnNameCombo = addLabeledEditableCombo( - container, - JptUiDetailsMessages.JoinColumnDialog_referencedColumnName, - buildReferencedColumnNamesListHolder(), - buildReferencedColumnNameHolder(), - buildReferencedColumnNameStringConverter(), - JpaHelpContextIds.MAPPING_JOIN_REFERENCED_COLUMN - ); - - SWTUtil.attachDefaultValueHandler(referencedColumnNameCombo); - - // Table widgets - if (isTableEditable()) { - - Combo tableCombo = addLabeledEditableCombo( - container, - JptUiDetailsMessages.JoinColumnDialogPane_table, - buildTablesListHolder(), - buildTableHolder(), - buildTableStringConverter(), - JpaHelpContextIds.MAPPING_JOIN_REFERENCED_COLUMN - ); - - SWTUtil.attachDefaultValueHandler(tableCombo); - } - else { - Combo tableCombo = addLabeledCombo( - container, - JptUiDetailsMessages.JoinColumnDialogPane_table, - buildTablesListHolder(), - buildTableHolder(), - buildTableStringConverter(), - JpaHelpContextIds.MAPPING_JOIN_REFERENCED_COLUMN - ); - - tableCombo.setEnabled(false); - } - - // Column Definition widgets - addLabeledText( - container, - JptUiDetailsMessages.JoinColumnDialogPane_columnDefinition, - buildColumnDefinitionHolder() - ); - } - - /** - * Determines whether the table combo should be editable or not. The default - * is to keep the combo read-only. - * - * @return <code>true</code> to support the editing of the selected table; - * <code>false</code> otherwise - */ - protected boolean isTableEditable() { - return false; - } - - protected static interface DefaultValueHandler { - String getDefaultValue(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnStateObject.java deleted file mode 100644 index 044e5398bc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BaseJoinColumnStateObject.java +++ /dev/null @@ -1,389 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.common.utility.internal.node.AbstractNode; -import org.eclipse.jpt.common.utility.internal.node.Node; -import org.eclipse.jpt.jpa.core.context.BaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.db.Table; - -/** - * The abstract definition of a state object used to edit or create a new - * join column. - * - * @see AbstractJoinColumn - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public abstract class BaseJoinColumnStateObject - extends AbstractNode -{ - /** - * The SQL fragment that is used when generating the DDL for the column. - */ - private String columnDefinition; - - /** - * Either the join column is being edited or <code>null</code> the state - * object is being created. - */ - private ReadOnlyBaseJoinColumn joinColumn; - - /** - * The join column's name or <code>null</code> if not defined. - */ - private String name; - - /** - * The owner of the join column to create or where it is located. - */ - private Object owner; - - /** - * The referenced column name or <code>null</code> if not defined. - */ - private String referencedColumnName; - - /** - * The table - */ - private String table; - - /** - * Keeps track of the <code>Validator</code> since this is the root object. - */ - private Validator validator; - - /** - * Identifies a change in the column definition property. - */ - public static final String COLUMN_DEFINITION_PROPERTY = "columnDefinition"; - - /** - * Identifies a change in the name property. - */ - public static final String NAME_PROPERTY = "name"; - - /** - * Identifies a change in the list of names. - */ - public static final String NAMES_LIST = "names"; - - /** - * Identifies a change in the list of reference column names. - */ - public static final String REFERENCE_COLUMN_NAMES_LIST = "referenceColumnNames"; - - /** - * Identifies a change in the referenced column name property. - */ - public static final String REFERENCED_COLUMN_NAME_PROPERTY = "referencedColumnName"; - - /** - * Identifies a change in the table property. - */ - public static final String TABLE_PROPERTY = "table"; - - /** - * Creates a new <code>AbstractJoinColumnStateObject</code>. - * - * @param owner The owner of the join column to create or where it is located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public BaseJoinColumnStateObject(Object owner, ReadOnlyBaseJoinColumn joinColumn) { - super(null); - initialize(owner, joinColumn); - } - - @Override - protected final void checkParent(Node parentNode) { - // This is the root of the Join Column state object - } - - private static ListIterator<String> columnNames(Table table) { - if (table == null) { - return EmptyListIterator.instance(); - } - return CollectionTools.list(table.getSortedColumnIdentifiers()).listIterator(); - } - - private static int columnsSize(Table table) { - if (table == null) { - return 0; - } - return table.getColumnsSize(); - } - - public final String displayString() { - return ""; - } - - /** - * Returns the SQL fragment that is used when generating the DDL for the - * column. - * - * @return The edited column name or <code>null</code> if not used - */ - public String getColumnDefinition() { - return columnDefinition; - } - - /** - * Returns the default name if the join column is being edited otherwise - * <code>null</code> is returned. - * - * @return Either the default name defined by the join column or <code>null</code> - */ - public String getDefaultName() { - return (this.joinColumn == null) ? null : this.joinColumn.getDefaultName(); - } - - /** - * Returns the default referenced column name if the join column is being - * edited otherwise <code>null</code> is returned. - * - * @return Either the default referenced column name defined by the join - * column or <code>null</code> - */ - public String getDefaultReferencedColumnName() { - if (this.joinColumn == null) { - return null; - } - - return this.joinColumn.getDefaultReferencedColumnName(); - } - - /** - * Returns - * - * @return - */ - public abstract String getDefaultTable(); - - /** - * Returns the edited join column or <code>null</code> if this state object - * is used to create a new one. - * - * @return The edited join column or <code>null</code> - */ - public ReadOnlyBaseJoinColumn getJoinColumn() { - return this.joinColumn; - } - - /** - * Returns the name of the join column. - * - * @return Either join column's name or <code>null</code> to use the default - * name - */ - public String getName() { - return this.name; - } - - /** - * Returns the database table if one can be found. - * - * @return The database table - */ - public abstract Table getNameTable(); - - /** - * Returns the owner where the join column is located or where a new one can - * be added. - * - * @return The parent of the join column - */ - public Object getOwner() { - return owner; - } - - /** - * Returns the referenced column name of the join column. - * - * @return Either join column's referenced column name or <code>null</code> - * to use the default name - */ - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - /** - * Returns - * - * @return - */ - public abstract Table getReferencedNameTable(); - - /** - * Returns - * - * @return - */ - public String getTable() { - return table; - } - - @Override - public final Validator getValidator() { - return this.validator; - } - - @Override - protected void initialize() { - super.initialize(); - validator = NULL_VALIDATOR; - } - - /** - * Initializes this state object. - * - * @param owner The owner of the join column to create or where it is located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - protected void initialize(Object o, ReadOnlyBaseJoinColumn jc) { - - this.owner = o; - this.joinColumn = jc; - this.table = this.getInitialTable(); - - if (jc != null) { - this.name = jc.getSpecifiedName(); - this.columnDefinition = jc.getColumnDefinition(); - this.referencedColumnName = jc.getSpecifiedReferencedColumnName(); - } - } - - /** - * Returns - */ - protected abstract String getInitialTable(); - - /** - * Returns the column names if the database table can be resolved. - * - * @return The names of the table's columns or an empty iterator if the table - * can't be resolved - */ - public ListIterator<String> names() { - return columnNames(getNameTable()); - } - - public int columnsSize() { - return columnsSize(getNameTable()); - } - - /** - * Returns the reference column names if the database table can be resolved. - * - * @return The names of the table's columns or an empty iterator if the table - * can't be resolved - */ - public ListIterator<String> referenceColumnNames() { - return columnNames(getReferencedNameTable()); - } - - public int referenceColumnsSize() { - return columnsSize(getReferencedNameTable()); - } - - /** - * Sets the SQL fragment that is used when generating the DDL for the column. - * - * @param columnDefinition The new join column's column definition or - * <code>null</code> to clear the value - */ - public void setColumnDefinition(String columnDefinition) { - String oldColumnDefinition = this.columnDefinition; - this.columnDefinition = columnDefinition; - firePropertyChanged(COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, columnDefinition); - } - - /** - * Sets the name of the join column. - * - * @param name The new join column's name or <code>null</code> to use the - * default name - */ - public void setName(String name) { - String oldName = this.name; - this.name = name; - firePropertyChanged(NAME_PROPERTY, oldName, name); - } - - /** - * Sets the referenced column name of the join column. - * - * @param referencedColumnName The new join column's referenced column name - * or <code>null</code> to use the default referenced column name - */ - public void setReferencedColumnName(String referencedColumnName) { - String oldReferencedColumnName = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, oldReferencedColumnName, referencedColumnName); - } - - public void setTable(String table) { - ArrayList<String> oldNames = CollectionTools.list(this.names()); - ArrayList<String> oldRefColNames = CollectionTools.list(this.referenceColumnNames()); - String oldTable = this.table; - this.table = table; - this.firePropertyChanged(TABLE_PROPERTY, oldTable, table); - this.synchronizeList(this.names(), oldNames, NAMES_LIST); - this.synchronizeList(this.referenceColumnNames(), oldRefColNames, REFERENCE_COLUMN_NAMES_LIST); - } - - @Override - public final void setValidator(Validator validator) { - this.validator = validator; - } - - /** - * Retrieves the list of all the table names contains in the associated - * schema. The default returns an empty iterator. - * - * @return The names of the tables - */ - public ListIterator<String> tables() { - return EmptyListIterator.instance(); - } - - /** - * Updates the given join column with the values contained in this state - * object. - * - * @param joinColumn The join column to update - */ - public void updateJoinColumn(BaseJoinColumn jc) { - - // Name - if (valuesAreDifferent(name, jc.getSpecifiedName())) { - jc.setSpecifiedName(name); - } - - // Referenced Column Name - if (valuesAreDifferent(referencedColumnName, jc.getSpecifiedReferencedColumnName())) { - jc.setSpecifiedReferencedColumnName(referencedColumnName); - } - - // Column Definition - if (valuesAreDifferent(columnDefinition, jc.getColumnDefinition())) { - jc.setColumnDefinition(columnDefinition); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BasicMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BasicMappingComposite.java deleted file mode 100644 index 0070d5a8ab..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/BasicMappingComposite.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | EnumTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | LobComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see BasicMapping - * @see ColumnComposite - * @see EnumTypeComposite - * @see FetchTypeComposite - * @see LobComposite - * @see OptionalComposite - * @see TemporalTypeComposite - * - * @version 2.0 - * @since 1.0 - */ -public class BasicMappingComposite extends AbstractBasicMappingComposite<BasicMapping> -{ - /** - * Creates a new <code>BasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IBasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public BasicMappingComposite(PropertyValueModel<? extends BasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/CascadeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/CascadeComposite.java deleted file mode 100644 index 504c351f8c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/CascadeComposite.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Cascade; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Cascade --------------------------------------------------------------- | - * | | | | - * | | x All x Persist x Merge x Remove x Refresh | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Cascade - * @see RelationshipMapping - * @see ManyToManyMappingComposite - A container of this pane - * @see ManyToOneMappingComposite - A container of this pane - * @see OneToManyMappingComposite - A container of this pane - * @see OneToOneMappingComposite - A container of this pane - * - * @version 2.0 - * @since 1.0 - */ -public class CascadeComposite<T extends Cascade> extends Pane<T> -{ - /** - * Creates a new <code>CascadeComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of the subject <code>ICascade</code> - * @param parent The parent container - */ - public CascadeComposite( - Pane<? extends RelationshipMapping> parentPane, - PropertyValueModel<T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - /** - * Creates a new <code>ColumnComposite</code>. - * - * @param subjectHolder The holder of the subject <code>ICascade</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public CascadeComposite( - PropertyValueModel<T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) { - // Cascade group - Group cascadeGroup = addCascadeGroup(container); - - // Container of the check boxes - container = addSubPane(cascadeGroup, 5, 8, 0, 0, 0); - - addAllCheckBox(container); - addPersistCheckBox(container); - addMergeCheckBox(container); - addRemoveCheckBox(container); - addRefreshCheckBox(container); - } - - protected void addAllCheckBox(Composite container) { - // All check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_all, - buildCascadeTypeAllHolder(), - null); - } - - protected void addPersistCheckBox(Composite container) { - // Persist check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_persist, - buildCascadeTypePersistHolder(), - null); - } - - protected void addMergeCheckBox(Composite container) { - // Merge check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_merge, - buildCascadeTypeMergeHolder(), - null); - } - - protected void addRemoveCheckBox(Composite container) { - // Remove check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_remove, - buildCascadeTypeRemoveHolder(), - null); - } - - protected void addRefreshCheckBox(Composite container) { - // Refresh check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_refresh, - buildCascadeTypeRefreshHolder(), - null); - } - - protected Group addCascadeGroup(Composite container) { - return addTitledGroup( - container, - JptUiDetailsMessages.CascadeComposite_cascadeTitle); - } - - protected WritablePropertyValueModel<Boolean> buildCascadeTypeAllHolder() { - return new PropertyAspectAdapter<Cascade, Boolean>(getSubjectHolder(), Cascade.ALL_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isAll(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setAll(value); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildCascadeTypeMergeHolder() { - return new PropertyAspectAdapter<Cascade, Boolean>(getSubjectHolder(), Cascade.MERGE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isMerge(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setMerge(value); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildCascadeTypePersistHolder() { - return new PropertyAspectAdapter<Cascade, Boolean>(getSubjectHolder(), Cascade.PERSIST_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isPersist(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setPersist(value); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildCascadeTypeRefreshHolder() { - return new PropertyAspectAdapter<Cascade, Boolean>(getSubjectHolder(), Cascade.REFRESH_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isRefresh(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setRefresh(value); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildCascadeTypeRemoveHolder() { - return new PropertyAspectAdapter<Cascade, Boolean>(getSubjectHolder(), Cascade.REMOVE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isRemove(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setRemove(value); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ColumnComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ColumnComposite.java deleted file mode 100644 index f71f1ffbcd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ColumnComposite.java +++ /dev/null @@ -1,587 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Column; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.db.ColumnCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.DatabaseObjectCombo; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -public class ColumnComposite - extends Pane<ReadOnlyColumn> -{ - public ColumnComposite( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyColumn> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - public ColumnComposite( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyColumn> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets); - } - - public ColumnComposite( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyColumn> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets, - boolean parentManagePane) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets, parentManagePane); - } - - - private ColumnCombo<ReadOnlyColumn> addColumnCombo(Composite container) { - - return new ColumnCombo<ReadOnlyColumn>(this, container) { - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(ReadOnlyNamedColumn.DEFAULT_NAME_PROPERTY); - propertyNames.add(ReadOnlyNamedColumn.SPECIFIED_NAME_PROPERTY); - propertyNames.add(ReadOnlyBaseColumn.DEFAULT_TABLE_PROPERTY); - propertyNames.add(ReadOnlyBaseColumn.SPECIFIED_TABLE_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == ReadOnlyBaseColumn.DEFAULT_TABLE_PROPERTY || - propertyName == ReadOnlyBaseColumn.SPECIFIED_TABLE_PROPERTY) { - this.doPopulate(); - } else { - super.propertyChanged(propertyName); - } - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultName(); - } - - @Override - protected void setValue(String value) { - ((Column) this.getSubject()).setSpecifiedName(value); - } - - @Override - protected Table getDbTable_() { - Column column = this.getColumn(); - return (column == null) ? null : column.getDbTable(); - } - - protected Column getColumn() { - ReadOnlyColumn column = this.getSubject(); - return (column instanceof Column) ? (Column) column : null; - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedName(); - } - - @Override - protected String buildNullDefaultValueEntry() { - return NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - JptCommonUiMessages.NoneSelected); - } - - @Override - public String toString() { - return "ColumnComposite.columnCombo"; //$NON-NLS-1$ - } - }; - } - - WritablePropertyValueModel<String> buildColumnDefinitionHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, String>(getSubjectHolder(), ReadOnlyNamedColumn.COLUMN_DEFINITION_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getColumnDefinition(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - ((Column) this.subject).setColumnDefinition(value); - } - }; - } - - WritablePropertyValueModel<Boolean> buildInsertableHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>(getSubjectHolder(), ReadOnlyBaseColumn.SPECIFIED_INSERTABLE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedInsertable(); - } - - @Override - protected void setValue_(Boolean value) { - ((Column) this.subject).setSpecifiedInsertable(value); - } - }; - } - - PropertyValueModel<String> buildInsertableStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultInsertableHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_insertableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_insertable; - } - }; - } - - PropertyValueModel<Boolean> buildDefaultInsertableHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.SPECIFIED_INSERTABLE_PROPERTY, - ReadOnlyBaseColumn.DEFAULT_INSERTABLE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedInsertable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultInsertable()); - } - }; - } - - WritablePropertyValueModel<Boolean> buildNullableHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.SPECIFIED_NULLABLE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedNullable(); - } - - @Override - protected void setValue_(Boolean value) { - ((Column) this.subject).setSpecifiedNullable(value); - } - }; - } - - PropertyValueModel<String> buildNullableStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultNullableHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_nullableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_nullable; - } - }; - } - - PropertyValueModel<Boolean> buildDefaultNullableHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.SPECIFIED_NULLABLE_PROPERTY, - ReadOnlyBaseColumn.DEFAULT_NULLABLE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedNullable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultNullable()); - } - }; - } - - private Pane<ReadOnlyColumn> addTableCombo(Composite container) { - - return new DatabaseObjectCombo<ReadOnlyColumn>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(ReadOnlyBaseColumn.DEFAULT_TABLE_PROPERTY); - propertyNames.add(ReadOnlyBaseColumn.SPECIFIED_TABLE_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultTable(); - } - - @Override - protected void setValue(String value) { - ((Column) this.getSubject()).setSpecifiedTable(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedTable(); - } - - @Override - protected Iterable<String> getValues_() { - return CollectionTools.iterable(this.values()); - } - - protected Iterator<String> values() { - Column column = this.getColumn(); - return (column == null) ? null : column.candidateTableNames(); - } - - protected Column getColumn() { - ReadOnlyColumn column = this.getSubject(); - return (column instanceof Column) ? (Column) column : null; - } - - @Override - protected String buildNullDefaultValueEntry() { - return NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - JptCommonUiMessages.NoneSelected); - } - - @Override - public String toString() { - return "ColumnComposite.tableCombo"; //$NON-NLS-1$ - } - }; - } - - WritablePropertyValueModel<Boolean> buildUniqueHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.SPECIFIED_UNIQUE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedUnique(); - } - - @Override - protected void setValue_(Boolean value) { - ((Column) this.subject).setSpecifiedUnique(value); - } - }; - } - - PropertyValueModel<String> buildUniqueStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultUniqueHolder()) { - - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_uniqueWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_unique; - } - }; - } - - PropertyValueModel<Boolean> buildDefaultUniqueHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.SPECIFIED_UNIQUE_PROPERTY, - ReadOnlyBaseColumn.DEFAULT_UNIQUE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedUnique() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultUnique()); - } - }; - } - - WritablePropertyValueModel<Boolean> buildUpdatableHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.DEFAULT_UPDATABLE_PROPERTY, - ReadOnlyBaseColumn.SPECIFIED_UPDATABLE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedUpdatable(); - } - - @Override - protected void setValue_(Boolean value) { - ((Column) this.subject).setSpecifiedUpdatable(value); - } - }; - } - - PropertyValueModel<String> buildUpdatableStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultUpdatableHolder()) { - - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_updatableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_updatable; - } - }; - } - - PropertyValueModel<Boolean> buildDefaultUpdatableHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Boolean>( - getSubjectHolder(), - ReadOnlyBaseColumn.SPECIFIED_UPDATABLE_PROPERTY, - ReadOnlyBaseColumn.DEFAULT_UPDATABLE_PROPERTY) { - - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedUpdatable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultUpdatable()); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - // Column group pane - container = addTitledGroup( - container, - JptUiDetailsMessages.ColumnComposite_columnSection); - - // Column widgets - addLabeledComposite( - container, - JptUiDetailsMessages.ColumnComposite_name, - addColumnCombo(container), - JpaHelpContextIds.MAPPING_COLUMN); - - // Table widgets - addLabeledComposite( - container, - JptUiDetailsMessages.ColumnComposite_table, - addTableCombo(container), - JpaHelpContextIds.MAPPING_COLUMN_TABLE); - - // Details sub-pane - container = addCollapsibleSubSection( - container, - JptUiDetailsMessages.ColumnComposite_details, - new SimplePropertyValueModel<Boolean>(Boolean.FALSE)); - - new DetailsComposite(this, getSubjectHolder(), addSubPane(container, 0, 16)); - } - - protected class DetailsComposite extends Pane<ReadOnlyColumn> { - - public DetailsComposite( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyColumn> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - @Override - protected void initializeLayout(Composite container) { - // Insertable tri-state check box - addTriStateCheckBoxWithDefault( - addSubPane(container, 4), - JptUiDetailsMessages.ColumnComposite_insertable, - buildInsertableHolder(), - buildInsertableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_INSERTABLE); - - // Updatable tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_updatable, - buildUpdatableHolder(), - buildUpdatableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_UPDATABLE); - - // Unique tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_unique, - buildUniqueHolder(), - buildUniqueStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_UNIQUE); - - // Nullable tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_nullable, - buildNullableHolder(), - buildNullableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_NULLABLE); - - addLengthCombo(container); - addPrecisionCombo(container); - addScaleCombo(container); - - // Column Definition widgets - addLabeledText( - container, - JptUiDetailsMessages.ColumnComposite_columnDefinition, - buildColumnDefinitionHolder()); - } - - private void addLengthCombo(Composite container) { - new IntegerCombo<ReadOnlyColumn>(this, container) { - @Override - protected String getLabelText() { - return JptUiDetailsMessages.ColumnComposite_length; - } - - @Override - protected String getHelpId() { - return JpaHelpContextIds.MAPPING_COLUMN_LENGTH; - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Integer>(getSubjectHolder(), ReadOnlyColumn.DEFAULT_LENGTH_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultLength()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Integer>(getSubjectHolder(), ReadOnlyColumn.SPECIFIED_LENGTH_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedLength(); - } - - @Override - protected void setValue_(Integer value) { - ((Column) this.subject).setSpecifiedLength(value); - } - }; - } - }; - } - - private void addPrecisionCombo(Composite container) { - new IntegerCombo<ReadOnlyColumn>(this, container) { - @Override - protected String getLabelText() { - return JptUiDetailsMessages.ColumnComposite_precision; - } - - @Override - protected String getHelpId() { - return JpaHelpContextIds.MAPPING_COLUMN_PRECISION; - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Integer>(getSubjectHolder(), ReadOnlyColumn.DEFAULT_PRECISION_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultPrecision()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Integer>(getSubjectHolder(), ReadOnlyColumn.SPECIFIED_PRECISION_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedPrecision(); - } - - @Override - protected void setValue_(Integer value) { - ((Column) this.subject).setSpecifiedPrecision(value); - } - }; - } - }; - } - - private void addScaleCombo(Composite container) { - new IntegerCombo<ReadOnlyColumn>(this, container) { - @Override - protected String getLabelText() { - return JptUiDetailsMessages.ColumnComposite_scale; - } - - @Override - protected String getHelpId() { - return JpaHelpContextIds.MAPPING_COLUMN_SCALE; - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Integer>(getSubjectHolder(), ReadOnlyColumn.DEFAULT_SCALE_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultScale()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<ReadOnlyColumn, Integer>(getSubjectHolder(), ReadOnlyColumn.SPECIFIED_SCALE_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedScale(); - } - - @Override - protected void setValue_(Integer value) { - ((Column) this.subject).setSpecifiedScale(value); - } - }; - } - }; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/DiscriminatorColumnComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/DiscriminatorColumnComposite.java deleted file mode 100644 index e71826c251..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/DiscriminatorColumnComposite.java +++ /dev/null @@ -1,309 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.DiscriminatorColumn; -import org.eclipse.jpt.jpa.core.context.DiscriminatorType; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.NamedColumn; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.db.ColumnCombo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | > Discriminator Column | - * | | - * | ---------------------------------------------------- | - * | Name: | ColumnCombo |v| | - * | ---------------------------------------------------- | - * | ---------------------------------------------------- | - * | Type: | EnumComboViewer |v| | - * | ---------------------------------------------------- | - * | > Details | - * | | - * | ---------------------------------------------------- | - * | Column Definition: | I | | - * | ---------------------------------------------------- | - * | ------------- | - * | Length: | I |I| | - * | ------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see AbstractEntityComposite - The parent container - * @see ColumnCombo - * @see EnumComboViewer - * @see PrimaryKeyJoinColumnsComposite - * - * @version 2.0 - * @since 2.0 - */ -public class DiscriminatorColumnComposite<T extends Entity> extends Pane<T> { - - /** - * Creates a new <code>InheritanceComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public DiscriminatorColumnComposite(Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - @Override - protected void initializeLayout(Composite container) { - // Discriminator Column sub-pane - Composite discriminatorColumnContainer = addTitledGroup( - addSubPane(container, 10), - JptUiDetailsMessages.InheritanceComposite_discriminatorColumnGroupBox - ); - - PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder = - buildDiscriminatorColumnHolder(); - - // Name widgets - addLabeledComposite( - discriminatorColumnContainer, - JptUiDetailsMessages.DiscriminatorColumnComposite_name, - addDiscriminatorColumnCombo(container, discriminatorColumnHolder), - JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_COLUMN - ); - - // Discriminator Type widgets - addLabeledComposite( - discriminatorColumnContainer, - JptUiDetailsMessages.DiscriminatorColumnComposite_discriminatorType, - addDiscriminatorTypeCombo(container, discriminatorColumnHolder), - JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_TYPE - ); - - container = addCollapsibleSubSection( - discriminatorColumnContainer, - JptUiDetailsMessages.InheritanceComposite_detailsGroupBox, - new SimplePropertyValueModel<Boolean>(Boolean.FALSE) - ); - - new DetailsComposite(this, discriminatorColumnHolder, addSubPane(container, 0, 16)); - - new PaneEnabler(buildDiscriminatorColumnEnabledHolder(), this); - } - - private ColumnCombo<DiscriminatorColumn> addDiscriminatorColumnCombo( - Composite container, - PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) { - - return new ColumnCombo<DiscriminatorColumn>( - this, - discriminatorColumnHolder, - container) - { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(NamedColumn.SPECIFIED_NAME_PROPERTY); - propertyNames.add(NamedColumn.DEFAULT_NAME_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultName(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedName(value); - } - - @Override - protected Table getDbTable_() { - return getSubject().getDbTable(); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedName(); - } - - @Override - protected String buildNullDefaultValueEntry() { - return JptCommonUiMessages.NoneSelected; - } - }; - } - - private PropertyValueModel<DiscriminatorColumn> buildDiscriminatorColumnHolder() { - return new PropertyAspectAdapter<Entity, DiscriminatorColumn>(getSubjectHolder()) { - @Override - protected DiscriminatorColumn buildValue_() { - return this.subject.getDiscriminatorColumn(); - } - }; - } - - private EnumFormComboViewer<DiscriminatorColumn, DiscriminatorType> addDiscriminatorTypeCombo( - Composite container, - PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) { - - return new EnumFormComboViewer<DiscriminatorColumn, DiscriminatorType>( - this, - discriminatorColumnHolder, - container) - { - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE_PROPERTY); - propertyNames.add(DiscriminatorColumn.SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY); - } - - @Override - protected DiscriminatorType[] getChoices() { - return DiscriminatorType.values(); - } - - @Override - protected DiscriminatorType getDefaultValue() { - return getSubject().getDefaultDiscriminatorType(); - } - - @Override - protected String displayString(DiscriminatorType value) { - return buildDisplayString( - JptUiDetailsMessages.class, - DiscriminatorColumnComposite.class, - value - ); - } - - @Override - protected String nullDisplayString() { - return JptCommonUiMessages.NoneSelected; - } - - @Override - protected DiscriminatorType getValue() { - return getSubject().getSpecifiedDiscriminatorType(); - } - - @Override - protected void setValue(DiscriminatorType value) { - getSubject().setSpecifiedDiscriminatorType(value); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildDiscriminatorColumnEnabledHolder() { - return new PropertyAspectAdapter<Entity, Boolean>(getSubjectHolder(), Entity.SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.specifiedDiscriminatorColumnIsAllowed()); - } - }; - } - - protected class DetailsComposite extends Pane<DiscriminatorColumn> { - public DetailsComposite(Pane<?> parentPane, - PropertyValueModel<? extends DiscriminatorColumn> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - @Override - protected void initializeLayout(Composite container) { - // Length widgets - addLengthCombo(container); - - // Column Definition widgets - addLabeledText( - container, - JptUiDetailsMessages.ColumnComposite_columnDefinition, - buildColumnDefinitionHolder(getSubjectHolder()) - ); - } - - private void addLengthCombo(Composite container) { - new IntegerCombo<DiscriminatorColumn>(this, container) { - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.ColumnComposite_length; - } - - @Override - protected String getHelpId() { - return JpaHelpContextIds.MAPPING_COLUMN_LENGTH; - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<DiscriminatorColumn, Integer>(getSubjectHolder(), DiscriminatorColumn.DEFAULT_LENGTH_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultLength()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<DiscriminatorColumn, Integer>(getSubjectHolder(), DiscriminatorColumn.SPECIFIED_LENGTH_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedLength(); - } - - @Override - protected void setValue_(Integer value) { - this.subject.setSpecifiedLength(value); - } - }; - } - }; - } - - private WritablePropertyValueModel<String> buildColumnDefinitionHolder(PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) { - - return new PropertyAspectAdapter<DiscriminatorColumn, String>(discriminatorColumnHolder, NamedColumn.COLUMN_DEFINITION_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getColumnDefinition(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setColumnDefinition(value); - } - }; - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedIdMappingComposite.java deleted file mode 100644 index 6a118d24ba..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedIdMappingComposite.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.swt.widgets.Composite; - -public class EmbeddedIdMappingComposite - extends AbstractEmbeddedIdMappingComposite<EmbeddedIdMapping> -{ - public EmbeddedIdMappingComposite( - PropertyValueModel<? extends EmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeEmbeddedIdSection(Composite container) { - new EmbeddedMappingOverridesComposite( - this, - container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedMappingComposite.java deleted file mode 100644 index 8b6b16e292..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedMappingComposite.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * - * @version 2.3 - * @since 1.0 - */ -public class EmbeddedMappingComposite extends AbstractEmbeddedMappingComposite<EmbeddedMapping> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddedMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>EmbeddedMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public EmbeddedMappingComposite(PropertyValueModel<? extends EmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedMappingOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedMappingOverridesComposite.java deleted file mode 100644 index 8b0ec1b4fe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EmbeddedMappingOverridesComposite.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.BaseEmbeddedMapping; -import org.eclipse.swt.widgets.Composite; - -public class EmbeddedMappingOverridesComposite - extends AbstractEmbeddedMappingOverridesComposite<BaseEmbeddedMapping> -{ - public EmbeddedMappingOverridesComposite( - Pane<? extends BaseEmbeddedMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected boolean supportsAssociationOverrides() { - return false; - } - - @Override - protected PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder() { - return new PropertyAspectAdapter<BaseEmbeddedMapping, AttributeOverrideContainer>(getSubjectHolder()) { - @Override - protected AttributeOverrideContainer buildValue_() { - return this.subject.getAttributeOverrideContainer(); - } - }; - } - - @Override - protected PropertyValueModel<AssociationOverrideContainer> buildAssociationOverrideContainerHolder() { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EntityNameComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EntityNameComposite.java deleted file mode 100644 index 61ce5a3b4b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EntityNameComposite.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------ | - * | Entity Name: | I |v| | - * | ------------------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see AbstractEntityComposite - The parent container - * - * @version 2.3 - * @since 1.0 - */ -public class EntityNameComposite - extends Pane<Entity> -{ - /** - * Creates a new <code>EntityNameComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public EntityNameComposite( - Pane<? extends Entity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Combo combo = addLabeledEditableCombo( - container, - JptUiDetailsMessages.EntityNameComposite_name, - buildDefaultEntityNameListHolder(), - buildEntityNameHolder(), - JpaHelpContextIds.ENTITY_NAME); - - SWTUtil.attachDefaultValueHandler(combo); - } - - private ListValueModel<String> buildDefaultEntityNameListHolder() { - return new PropertyListValueModelAdapter<String>( - buildDefaultEntityNameHolder() - ); - } - - private PropertyValueModel<String> buildDefaultEntityNameHolder() { - return new PropertyAspectAdapter<Entity, String>(getSubjectHolder(), Entity.DEFAULT_NAME_PROPERTY) { - @Override - protected String buildValue_() { - return defaultValue(this.subject); - } - }; - } - - private WritablePropertyValueModel<String> buildEntityNameHolder() { - return new PropertyAspectAdapter<Entity, String>(getSubjectHolder(), Entity.SPECIFIED_NAME_PROPERTY, Entity.DEFAULT_NAME_PROPERTY) { - @Override - protected String buildValue_() { - - String name = this.subject.getSpecifiedName(); - - if (name == null) { - name = defaultValue(this.subject); - } - - return name; - } - - @Override - protected void setValue_(String value) { - - if (defaultValue(this.subject).equals(value)) { - value = null; - } - - this.subject.setSpecifiedName(value); - } - }; - } - - private String defaultValue(Entity subject) { - String defaultValue = subject.getDefaultName(); - - if (defaultValue != null) { - return NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - defaultValue - ); - } - return JptCommonUiMessages.DefaultEmpty; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EntityOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EntityOverridesComposite.java deleted file mode 100644 index 4087cd2f4d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EntityOverridesComposite.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.swt.widgets.Composite; - -public class EntityOverridesComposite - extends AbstractEntityOverridesComposite -{ - public EntityOverridesComposite( - Pane<? extends Entity> parentPane, - Composite parent) { - - super(parentPane, parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EnumTypeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EnumTypeComposite.java deleted file mode 100644 index d83d5d64e1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/EnumTypeComposite.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EnumType; -import org.eclipse.jpt.jpa.core.context.EnumeratedConverter; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | -------------------------------------------------------------- | - * | Enum Type: | |v| | - * | -------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see BasicMapping - * @see BasicMappingComposite - A container of this widget - * - * @version 2.0 - * @since 1.0 - */ -public class EnumTypeComposite extends Pane<EnumeratedConverter> -{ - /** - * Creates a new <code>EnumTypeComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public EnumTypeComposite(PropertyValueModel<? extends EnumeratedConverter> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - private EnumFormComboViewer<EnumeratedConverter, EnumType> addEnumTypeCombo(Composite container) { - - return new EnumFormComboViewer<EnumeratedConverter, EnumType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(EnumeratedConverter.SPECIFIED_ENUM_TYPE_PROPERTY); - } - - @Override - protected EnumType[] getChoices() { - return EnumType.values(); - } - - @Override - protected EnumType getDefaultValue() { - return getSubject().getDefaultEnumType(); - } - - @Override - protected String displayString(EnumType value) { - return buildDisplayString( - JptUiDetailsMessages.class, - EnumTypeComposite.this, - value - ); - } - - @Override - protected EnumType getValue() { - return getSubject().getSpecifiedEnumType(); - } - - @Override - protected void setValue(EnumType value) { - getSubject().setSpecifiedEnumType(value); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - //JpaHelpContextIds.MAPPING_ENUMERATED - addEnumTypeCombo(container); - - new PaneEnabler(buildBooleanHolder(), this); - } - - - protected PropertyValueModel<Boolean> buildBooleanHolder() { - return new TransformationPropertyValueModel<EnumeratedConverter, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(EnumeratedConverter value) { - if (getSubject() != null && getSubject().getParent().getPersistentAttribute().isVirtual()) { - return Boolean.FALSE; - } - return Boolean.valueOf(value != null); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/FetchTypeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/FetchTypeComposite.java deleted file mode 100644 index 843c39962d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/FetchTypeComposite.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.FetchType; -import org.eclipse.jpt.jpa.core.context.FetchableMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------ | - * | Fetch: | |v| | - * | ------------------------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see FetchableMapping - * @see BasicMappingComposite - A container of this widget - * @see ManyToManyMappingComposite - A container of this widget - * @see ManyToOneMappingComposite - A container of this widget - * @see OneToManyMappingComposite - A container of this widget - * @see OneToOneMappingComposite - A container of this widget - * - * @version 2.0 - * @since 1.0 - */ -public class FetchTypeComposite extends Pane<FetchableMapping> { - - /** - * Creates a new <code>FetchTypeComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public FetchTypeComposite(Pane<? extends FetchableMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - private EnumFormComboViewer<FetchableMapping, FetchType> addFetchTypeCombo(Composite container) { - - return new EnumFormComboViewer<FetchableMapping, FetchType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(FetchableMapping.DEFAULT_FETCH_PROPERTY); - propertyNames.add(FetchableMapping.SPECIFIED_FETCH_PROPERTY); - } - - @Override - protected FetchType[] getChoices() { - return FetchType.values(); - } - - @Override - protected FetchType getDefaultValue() { - return getSubject().getDefaultFetch(); - } - - @Override - protected String displayString(FetchType value) { - return buildDisplayString( - JptUiDetailsMessages.class, - FetchTypeComposite.this, - value - ); - } - - @Override - protected FetchType getValue() { - return getSubject().getSpecifiedFetch(); - } - - @Override - protected void setValue(FetchType value) { - getSubject().setSpecifiedFetch(value); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - addLabeledComposite( - container, - JptUiDetailsMessages.BasicGeneralSection_fetchLabel, - addFetchTypeCombo(container), - JpaHelpContextIds.MAPPING_FETCH_TYPE - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GeneratedValueComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GeneratedValueComposite.java deleted file mode 100644 index 5c32bbaecb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GeneratedValueComposite.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationListValueModel; -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.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.GeneratedValue; -import org.eclipse.jpt.jpa.core.context.GenerationType; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | --------------------------------------------------------- | - * | Strategy: | I |v| | - * | --------------------------------------------------------- | - * | --------------------------------------------------------- | - * | Generator Name: | I |v| | - * | --------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see IdMapping - * @see GeneratedValue - * @see IdMappingGenerationComposite - The parent container - * - * @version 2.3 - * @since 1.0 - */ -public class GeneratedValueComposite extends Pane<IdMapping> -{ - - /** - * Creates a new <code>GeneratedValueComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public GeneratedValueComposite(Pane<? extends IdMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - // Strategy widgets - addLabeledComposite( - container, - JptUiDetailsMessages.GeneratedValueComposite_strategy, - addStrategyComboViewer(container), - JpaHelpContextIds.MAPPING_GENERATED_VALUE_STRATEGY - ); - - addLabeledEditableCombo( - container, - JptUiDetailsMessages.GeneratedValueComposite_generatorName, - buildGeneratorNamesModel(), - buildGeneratorNameHolder(), - JpaHelpContextIds.MAPPING_GENERATED_VALUE_STRATEGY - ); - } - - private EnumFormComboViewer<GeneratedValue, GenerationType> addStrategyComboViewer(Composite parent) { - - return new EnumFormComboViewer<GeneratedValue, GenerationType>(this, buildGeneratedValueHolder(), parent) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(GeneratedValue.DEFAULT_STRATEGY_PROPERTY); - propertyNames.add(GeneratedValue.SPECIFIED_STRATEGY_PROPERTY); - } - - @Override - protected GenerationType[] getChoices() { - return GenerationType.values(); - } - - @Override - protected GenerationType getDefaultValue() { - return getSubject().getDefaultStrategy(); - } - - @Override - protected String displayString(GenerationType value) { - return buildDisplayString( - JptUiDetailsMessages.class, - GeneratedValueComposite.this, - value - ); - } - - @Override - protected GenerationType getValue() { - return getSubject().getSpecifiedStrategy(); - } - - @Override - protected void setValue(GenerationType value) { - retrieveGeneratedValue().setSpecifiedStrategy(value); - } - }; - } - - private PropertyValueModel<GeneratedValue> buildGeneratedValueHolder() { - return new PropertyAspectAdapter<IdMapping, GeneratedValue>(getSubjectHolder(), IdMapping.GENERATED_VALUE_PROPERTY) { - @Override - protected GeneratedValue buildValue_() { - return getSubject().getGeneratedValue(); - } - }; - } - - protected final WritablePropertyValueModel<String> buildGeneratorNameHolder() { - return new PropertyAspectAdapter<GeneratedValue, String>(buildGeneratedValueHolder(), GeneratedValue.SPECIFIED_GENERATOR_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getSpecifiedGenerator(); - } - - @Override - public void setValue(String value) { - if (this.subject != null) { - setValue_(value); - return; - } - if (value.length() == 0) { - return; - } - retrieveGeneratedValue().setSpecifiedGenerator(value); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setSpecifiedGenerator(value); - } - }; - } - - protected ListValueModel<String> buildGeneratorNamesModel() { - return new TransformationListValueModel<Generator, String>(this.buildSortedGeneratorsModel()) { - @Override - protected String transformItem_(Generator item) { - return item.getName(); - } - }; - } - - protected ListValueModel<Generator> buildSortedGeneratorsModel() { - return new SortedListValueModelAdapter<Generator>(this.buildGeneratorsModel(), GENERATOR_COMPARATOR); - } - - protected static final Comparator<Generator> GENERATOR_COMPARATOR = new Comparator<Generator>() { - public int compare(Generator generator1, Generator generator2) { - return generator1.getName().compareTo(generator2.getName()); - } - }; - - protected CollectionValueModel<Generator> buildGeneratorsModel() { - return new CollectionAspectAdapter<PersistenceUnit, Generator>(this.buildPersistenceUnitModel(), PersistenceUnit.GENERATORS_COLLECTION) { - @Override - protected Iterator<Generator> iterator_() { - return this.subject.generators(); - } - @Override - protected int size_() { - return this.subject.generatorsSize(); - } - }; - } - - protected PropertyValueModel<PersistenceUnit> buildPersistenceUnitModel() { - return new PropertyAspectAdapter<IdMapping, PersistenceUnit>(getSubjectHolder()) { - @Override - protected PersistenceUnit buildValue_() { - return getSubject().getPersistenceUnit(); - } - }; - } - - private GeneratedValue retrieveGeneratedValue() { - GeneratedValue generatedValue = getSubject().getGeneratedValue(); - - if (generatedValue == null) { - generatedValue = getSubject().addGeneratedValue(); - } - return generatedValue; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GenerationComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GenerationComposite.java deleted file mode 100644 index da1ee61f4e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GenerationComposite.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.context.TableGenerator; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | v Table Generator | - * | | - * | x Table Generator | - * | ----------------------------------------------------------------------- | - * | | | | - * | | TableGeneratorComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * | | - * | v Sequence Generator | - * | | - * | x Sequence Generator | - * | ----------------------------------------------------------------------- | - * | | | | - * | | SequenceGeneratorComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see GeneratorContainer - * @see TableGeneratorComposite - * @see SequenceGeneratorComposite - * @see AbstractEntityComposite - The parent container - * - * @version 2.2 - * @since 2.0 - */ -public class GenerationComposite extends Pane<GeneratorContainer> -{ - - //These are built to stand alone because we do not want the panels to collapse just - //because the generator is removed either in the source or using the check box in the UI. - //We don't want these to be built on the model generator properties. - private WritablePropertyValueModel<Boolean> sequenceGeneratorExpansionStateHolder; - private WritablePropertyValueModel<Boolean> tableGeneratorExpansionStateHolder; - - - public GenerationComposite( - Pane<?> parentPane, - PropertyValueModel<? extends GeneratorContainer> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - @Override - protected void initialize() { - super.initialize(); - this.sequenceGeneratorExpansionStateHolder = new SimplePropertyValueModel<Boolean>(Boolean.FALSE); - this.tableGeneratorExpansionStateHolder = new SimplePropertyValueModel<Boolean>(Boolean.FALSE); - } - - @Override - protected void doPopulate() { - super.doPopulate(); - this.sequenceGeneratorExpansionStateHolder.setValue(Boolean.valueOf(getSubject() != null && getSubject().getSequenceGenerator() != null)); - this.tableGeneratorExpansionStateHolder .setValue(Boolean.valueOf(getSubject() != null && getSubject().getTableGenerator() != null)); - } - - @Override - protected void initializeLayout(Composite container) { - - this.initializeTableGeneratorPane(container); - this.initializeSequenceGeneratorPane(container); - } - - private void initializeSequenceGeneratorPane(Composite container) { - - // Sequence Generator sub-section - container = this.addCollapsibleSubSection( - this.addSubPane(container, 10), - JptUiDetailsMessages.GeneratorsComposite_sequenceGeneratorSection, - this.sequenceGeneratorExpansionStateHolder - ); - - // Sequence Generator check box - Button sequenceGeneratorCheckBox = addCheckBox( - this.addSubPane(container, 5), - JptUiDetailsMessages.GeneratorsComposite_sequenceGeneratorCheckBox, - this.buildSequenceGeneratorBooleanHolder(), - JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR - ); - - // Sequence Generator pane - this.addSequenceGeneratorComposite(container, 0, sequenceGeneratorCheckBox.getBorderWidth() + 16); - } - - protected void addSequenceGeneratorComposite(Composite container, int topMargin, int leftMargin) { - new SequenceGeneratorComposite( - this, - this.buildSequenceGeneratorHolder(), - this.addSubPane(container, topMargin, leftMargin), - this.buildSequenceGeneratorBuilder() - ); - } - - protected PropertyValueModel<SequenceGenerator> buildSequenceGeneratorHolder() { - return new PropertyAspectAdapter<GeneratorContainer, SequenceGenerator>(getSubjectHolder(), GeneratorContainer.SEQUENCE_GENERATOR_PROPERTY) { - @Override - protected SequenceGenerator buildValue_() { - return this.subject.getSequenceGenerator(); - } - }; - } - - protected GeneratorBuilder<SequenceGenerator> buildSequenceGeneratorBuilder() { - return new GeneratorBuilder<SequenceGenerator>() { - public SequenceGenerator addGenerator() { - return getSubject().addSequenceGenerator(); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildSequenceGeneratorBooleanHolder() { - return new PropertyAspectAdapter<GeneratorContainer, Boolean>(getSubjectHolder(), GeneratorContainer.SEQUENCE_GENERATOR_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getSequenceGenerator() != null); - } - - @Override - protected void setValue_(Boolean value) { - - if (value.booleanValue() && (this.subject.getSequenceGenerator() == null)) { - this.subject.addSequenceGenerator(); - } - else if (!value.booleanValue() && (this.subject.getSequenceGenerator() != null)) { - this.subject.removeSequenceGenerator(); - } - } - }; - } - - private void initializeTableGeneratorPane(Composite container) { - - // Table Generator sub-section - container = addCollapsibleSubSection( - container, - JptUiDetailsMessages.GeneratorsComposite_tableGeneratorSection, - this.tableGeneratorExpansionStateHolder - ); - - Button tableGeneratorCheckBox = addCheckBox( - this.addSubPane(container, 5), - JptUiDetailsMessages.GeneratorsComposite_tableGeneratorCheckBox, - this.buildTableGeneratorBooleanHolder(), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR - ); - - - // Table Generator pane - new TableGeneratorComposite( - this, - this.buildTableGeneratorHolder(), - this.addSubPane(container, 0, tableGeneratorCheckBox.getBorderWidth() + 16), - this.buildTableGeneratorBuilder() - ); - } - - private PropertyValueModel<TableGenerator> buildTableGeneratorHolder() { - return new PropertyAspectAdapter<GeneratorContainer, TableGenerator>(getSubjectHolder(), GeneratorContainer.TABLE_GENERATOR_PROPERTY) { - @Override - protected TableGenerator buildValue_() { - return this.subject.getTableGenerator(); - } - }; - } - - private GeneratorBuilder<TableGenerator> buildTableGeneratorBuilder() { - return new GeneratorBuilder<TableGenerator>() { - public TableGenerator addGenerator() { - return getSubject().addTableGenerator(); - } - }; - } - - protected PropertyValueModel<Boolean> buildTableGeneratorExpanstionStateHolder() { - return new PropertyAspectAdapter<GeneratorContainer, Boolean>(getSubjectHolder(), GeneratorContainer.TABLE_GENERATOR_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getTableGenerator() != null); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildTableGeneratorBooleanHolder() { - return new PropertyAspectAdapter<GeneratorContainer, Boolean>(getSubjectHolder(), GeneratorContainer.TABLE_GENERATOR_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getTableGenerator() != null); - } - - @Override - protected void setValue_(Boolean value) { - - if (value.booleanValue() && (this.subject.getTableGenerator() == null)) { - this.subject.addTableGenerator(); - } - else if (!value.booleanValue() && (this.subject.getTableGenerator() != null)) { - this.subject.removeTableGenerator(); - } - } - }; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GeneratorComposite.java deleted file mode 100644 index 62beecbbf8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/GeneratorComposite.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.swt.widgets.Composite; - -/** - * This is the generic pane for a generator. - * - * @see IdMapping - * @see Generator - * @see SequenceGeneratorComposite - A sub-pane - * @see TalbeGeneratorComposite - A sub-pane - * - * @version 2.2 - * @since 1.0 - */ -public abstract class GeneratorComposite<T extends Generator> extends Pane<T> -{ - - protected GeneratorBuilder<T> generatorBuilder; - - protected GeneratorComposite(Pane<?> parentPane, - PropertyValueModel<T> subjectHolder, - Composite parent, - GeneratorBuilder<T> generatorBuilder) { - - super(parentPane, subjectHolder, parent, false); - this.generatorBuilder = generatorBuilder; - } - - /** - * Creates a new Generator. This makes it possible for the user - * to set values on a Generator before the model object has been created. - * Allows them not to first have to check the check box to enable the panel. - */ - protected final T buildGenerator() { - return this.generatorBuilder.addGenerator(); - } - - /** - * Retrieves the <code>Generator</code> and if it is <code>null</code>, then - * create it. - * - * @param subject The subject used to retrieve the generator - * @return The <code>Generator</code> which should never be <code>null</code> - */ - protected final T retrieveGenerator() { - T generator = getSubject(); - - if (generator == null) { - generator = this.buildGenerator(); - } - - return generator; - } - - protected final WritablePropertyValueModel<String> buildGeneratorNameHolder() { - return new PropertyAspectAdapter<Generator, String>(getSubjectHolder(), Generator.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getName(); - } - - @Override - public void setValue(String value) { - if (this.subject != null) { - setValue_(value); - return; - } - if (value.length() == 0) { - return; - } - retrieveGenerator().setName(value); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setName(value); - } - }; - } - - protected void addAllocationSizeCombo(Composite container) { - new IntegerCombo<Generator>(this, getSubjectHolder(), container) { - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.GeneratorComposite_allocationSize; - } - - @Override - protected String getHelpId() { - return null;//JpaHelpContextIds.MAPPING_COLUMN_LENGTH; - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_ALLOCATION_SIZE_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultAllocationSize()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedAllocationSize(); - } - - @Override - public void setValue(Integer value) { - retrieveGenerator().setSpecifiedAllocationSize(value); - } - }; - } - }; - } - - protected void addInitialValueCombo(Composite container) { - new IntegerCombo<Generator>(this, getSubjectHolder(), container) { - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.GeneratorComposite_initialValue; - } - - @Override - protected String getHelpId() { - return null;//JpaHelpContextIds.MAPPING_COLUMN_LENGTH; - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_INITIAL_VALUE_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultInitialValue()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_INITIAL_VALUE_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedInitialValue(); - } - - @Override - public void setValue(Integer value) { - retrieveGenerator().setSpecifiedInitialValue(value); - } - }; - } - }; - } - - /** - * Retrieves the JPA project. - * - * @return The JPA project or <code>null</code> if the subject is <code>null</code> - */ - protected final JpaProject getJpaProject() { - return this.getSubject() == null ? null : this.getSubject().getJpaProject(); - } - - /** - * Returns the property name used to listen to the ID mapping when the - * generator changes. - * - * @return The property name associated with the generator - */ - protected abstract String getPropertyName(); - - - public interface GeneratorBuilder<T> { - /** - * Add a generator to the model and return it - */ - T addGenerator(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdClassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdClassComposite.java deleted file mode 100644 index fc4d85dfd5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdClassComposite.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserComboPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.IdClassReference; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Id class hyperlink label, combo, and browse button - * - */ -public class IdClassComposite - extends Pane<IdClassReference> -{ - /** - * Creates a new <code>IdClassComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public IdClassComposite( - Pane<?> parentPane, - PropertyValueModel<? extends IdClassReference> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - public IdClassComposite( - Pane<?> parentPane, - PropertyValueModel<? extends IdClassReference> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets); - } - - - @Override - protected void initializeLayout(Composite container) { - new IdClassChooserComboPane(this, container); - } - - - private class IdClassChooserComboPane - extends ClassChooserComboPane<IdClassReference> - { - public IdClassChooserComboPane(Pane<IdClassReference> parentPane, Composite parent) { - super(parentPane, parent); - } - - - @Override - protected String getClassName() { - return getSubject().getIdClassName(); - } - - @Override - protected void setClassName(String className) { - getSubject().setSpecifiedIdClassName(className); - } - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.IdClassComposite_label; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected char getEnclosingTypeSeparator() { - return getSubject().getIdClassEnclosingTypeSeparator(); - } - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<IdClassReference, String>( - getSubjectHolder(), - IdClassReference.SPECIFIED_ID_CLASS_NAME_PROPERTY, - IdClassReference.DEFAULT_ID_CLASS_NAME_PROPERTY) { - - @Override - protected String buildValue_() { - String value = this.subject.getSpecifiedIdClassName(); - return (value == null) ? defaultText(this.subject) : value; - } - - @Override - protected void setValue_(String value) { - if (value == null - || value.length() == 0 - || value.equals(defaultText(this.subject))) { - value = null; - } - this.subject.setSpecifiedIdClassName(value); - } - }; - } - - protected String defaultText(IdClassReference idClassReference) { - String defaultClassName = idClassReference.getDefaultIdClassName(); - return (defaultClassName == null) ? - JptCommonUiMessages.NoneSelected - : NLS.bind(JptCommonUiMessages.DefaultWithOneParam, defaultClassName); - } - - @Override - protected ListValueModel<String> buildClassListHolder() { - return new PropertyListValueModelAdapter<String>( - new PropertyAspectAdapter<IdClassReference, String>( - getSubjectHolder(), IdClassReference.DEFAULT_ID_CLASS_NAME_PROPERTY) { - @Override - protected String buildValue_() { - return defaultText(this.subject); - } - }); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdMappingComposite.java deleted file mode 100644 index 617adaadf1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdMappingComposite.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.swt.widgets.Composite; - -public class IdMappingComposite - extends AbstractIdMappingComposite<IdMapping> -{ - public IdMappingComposite( - PropertyValueModel<? extends IdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeIdSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdMappingGenerationComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdMappingGenerationComposite.java deleted file mode 100644 index 85e4b40eda..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/IdMappingGenerationComposite.java +++ /dev/null @@ -1,348 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.GeneratedValue; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.context.TableGenerator; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** - * This panel is partially a copy of the GenerationComposite panel. The difference - * is that this panel includes the Generated Value composite. When a table - * or sequence generator is added, we set the "name" to be the same as the - * generated value "generator" if it already exists - * - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | v Primary Key Generation | - * | | - * | x Primary Key Generation | - * | --------------------------------------------------------------------- | - * | | | | - * | | GeneratedValueComposite | | - * | | | | - * | --------------------------------------------------------------------- | - * | | - * | v Table Generator | - * | | - * | x Table Generator | - * | --------------------------------------------------------------------- | - * | | | | - * | | TableGeneratorComposite | | - * | | | | - * | --------------------------------------------------------------------- | - * | | - * | v Sequence Generator | - * | | - * | x Sequence Generator | - * | --------------------------------------------------------------------- | - * | | | | - * | | SequenceGeneratorComposite | | - * | | | | - * | --------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see IdMapping - * @see GeneratedValueComposite - * @see TableGeneratorComposite - * @see SequenceGeneratorComposite - * @see IdMappingComposite - The parent container - * - * @version 2.2 - * @since 1.0 - */ -public class IdMappingGenerationComposite extends Pane<IdMapping> -{ - - //These are built to stand alone because we do not want the panels to collapse just - //because the generator is removed either in the source or using the check box in the UI. - //We don't want these to be built on the model generator properties. - private WritablePropertyValueModel<Boolean> sequenceGeneratorExpansionStateHolder; - private WritablePropertyValueModel<Boolean> tableGeneratorExpansionStateHolder; - - - /** - * Creates a new <code>GenerationComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public IdMappingGenerationComposite(Pane<? extends IdMapping> parentPane, - Composite parent) - { - super(parentPane, parent, false); - } - - @Override - protected void initialize() { - super.initialize(); - this.sequenceGeneratorExpansionStateHolder = new SimplePropertyValueModel<Boolean>(Boolean.FALSE); - this.tableGeneratorExpansionStateHolder = new SimplePropertyValueModel<Boolean>(Boolean.FALSE); - } - - @Override - protected void doPopulate() { - super.doPopulate(); - this.sequenceGeneratorExpansionStateHolder.setValue(Boolean.valueOf(getSubject() != null && getSubject().getGeneratorContainer().getSequenceGenerator() != null)); - this.tableGeneratorExpansionStateHolder .setValue(Boolean.valueOf(getSubject() != null && getSubject().getGeneratorContainer().getTableGenerator() != null)); - } - - @Override - protected void initializeLayout(Composite container) { - - // Primary Key Generation section - container = addCollapsibleSection( - container, - JptUiDetailsMessages.IdMappingComposite_primaryKeyGenerationSection, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - // Primary Key Generation check box - Button primaryKeyGenerationCheckBox = addCheckBox( - container, - JptUiDetailsMessages.IdMappingComposite_primaryKeyGenerationCheckBox, - buildPrimaryKeyGenerationHolder(), - JpaHelpContextIds.MAPPING_PRIMARY_KEY_GENERATION - ); - - // Generated Value widgets - GeneratedValueComposite generatedValueComposite = new GeneratedValueComposite( - this, - container - ); - - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalIndent = primaryKeyGenerationCheckBox.getBorderWidth() + 16; - - generatedValueComposite.getControl().setLayoutData(gridData); - - PropertyValueModel<GeneratorContainer> generatorHolder = buildGeneratorContainer(); - // Table Generator pane - initializeTableGeneratorPane(addSubPane(container, 10), generatorHolder); - - // Sequence Generator pane - initializeSequenceGeneratorPane(addSubPane(container, 10), generatorHolder); - } - - private WritablePropertyValueModel<Boolean> buildPrimaryKeyGenerationHolder() { - return new PropertyAspectAdapter<IdMapping, Boolean>(getSubjectHolder(), IdMapping.GENERATED_VALUE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getGeneratedValue() != null); - } - - @Override - protected void setValue_(Boolean value) { - - if (value.booleanValue() && (this.subject.getGeneratedValue() == null)) { - this.subject.addGeneratedValue(); - } - else if (!value.booleanValue() && (this.subject.getGeneratedValue() != null)) { - this.subject.removeGeneratedValue(); - } - } - }; - } - - private PropertyValueModel<GeneratorContainer> buildGeneratorContainer() { - return new PropertyAspectAdapter<IdMapping, GeneratorContainer>(getSubjectHolder()) { - @Override - protected GeneratorContainer buildValue_() { - return this.subject.getGeneratorContainer(); - } - }; - } - - private void initializeSequenceGeneratorPane(Composite container, PropertyValueModel<GeneratorContainer> generatorHolder) { - - // Sequence Generator sub-section - container = addCollapsibleSubSection( - container, - JptUiDetailsMessages.IdMappingComposite_sequenceGeneratorSection, - this.sequenceGeneratorExpansionStateHolder - ); - - // Sequence Generator check box - Button sequenceGeneratorCheckBox = addCheckBox( - container, - JptUiDetailsMessages.IdMappingComposite_sequenceGeneratorCheckBox, - buildSequenceGeneratorBooleanHolder(generatorHolder), - JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR - ); - - // Sequence Generator pane - this.buildSequenceGeneratorComposite( - container, - buildSequenceGeneratorHolder(generatorHolder), - buildSequenceGeneratorBuilder(generatorHolder), - 0, - sequenceGeneratorCheckBox.getBorderWidth() + 16); - } - - private WritablePropertyValueModel<Boolean> buildSequenceGeneratorBooleanHolder(PropertyValueModel<GeneratorContainer> generatorHolder) { - return new PropertyAspectAdapter<GeneratorContainer, Boolean>(generatorHolder, GeneratorContainer.SEQUENCE_GENERATOR_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getSequenceGenerator() != null); - } - - @Override - protected void setValue_(Boolean value) { - - if (value.booleanValue() && (this.subject.getSequenceGenerator() == null)) { - - SequenceGenerator sequenceGenerator = this.subject.addSequenceGenerator(); - GeneratedValue generatedValue = getSubject().getGeneratedValue(); - - if ((generatedValue != null) && - (generatedValue.getGenerator() != null)) - { - sequenceGenerator.setName(generatedValue.getGenerator()); - } - } - else if (!value.booleanValue() && (this.subject.getSequenceGenerator() != null)) { - this.subject.removeSequenceGenerator(); - } - } - }; - } - - protected SequenceGeneratorComposite buildSequenceGeneratorComposite( - Composite container, - PropertyValueModel<SequenceGenerator> sequenceGeneratorHolder, - GeneratorBuilder<SequenceGenerator> generatorBuilder, - int topMargin, - int leftMargin) { - - return new SequenceGeneratorComposite( - this, - sequenceGeneratorHolder, - this.addSubPane(container, topMargin, leftMargin), - generatorBuilder - ); - } - - private PropertyValueModel<SequenceGenerator> buildSequenceGeneratorHolder(PropertyValueModel<GeneratorContainer> generatorHolder) { - return new PropertyAspectAdapter<GeneratorContainer, SequenceGenerator>(generatorHolder, GeneratorContainer.SEQUENCE_GENERATOR_PROPERTY) { - @Override - protected SequenceGenerator buildValue_() { - return this.subject.getSequenceGenerator(); - } - }; - } - private GeneratorBuilder<SequenceGenerator> buildSequenceGeneratorBuilder(final PropertyValueModel<GeneratorContainer> generatorHolder) { - return new GeneratorBuilder<SequenceGenerator>() { - public SequenceGenerator addGenerator() { - return generatorHolder.getValue().addSequenceGenerator(); - } - }; - } - - private void initializeTableGeneratorPane(Composite container, PropertyValueModel<GeneratorContainer> generatorHolder) { - - // Table Generator sub-section - container = addCollapsibleSubSection( - container, - JptUiDetailsMessages.IdMappingComposite_tableGeneratorSection, - this.tableGeneratorExpansionStateHolder - ); - - Button tableGeneratorCheckBox = addCheckBox( - container, - JptUiDetailsMessages.IdMappingComposite_tableGeneratorCheckBox, - buildTableGeneratorBooleanHolder(generatorHolder), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR - ); - - // Sequence Generator pane - this.buildTableGeneratorComposite( - container, - buildTableGeneratorHolder(generatorHolder), - buildTableGeneratorBuilder(generatorHolder), - 0, - tableGeneratorCheckBox.getBorderWidth() + 16); - } - - protected TableGeneratorComposite buildTableGeneratorComposite( - Composite container, - PropertyValueModel<TableGenerator> tableGeneratorHolder, - GeneratorBuilder<TableGenerator> generatorBuilder, - int topMargin, - int leftMargin) { - - return new TableGeneratorComposite( - this, - tableGeneratorHolder, - this.addSubPane(container, topMargin, leftMargin), - generatorBuilder - ); - } - - private PropertyValueModel<TableGenerator> buildTableGeneratorHolder(PropertyValueModel<GeneratorContainer> generatorHolder) { - return new PropertyAspectAdapter<GeneratorContainer, TableGenerator>(generatorHolder, GeneratorContainer.TABLE_GENERATOR_PROPERTY) { - @Override - protected TableGenerator buildValue_() { - return this.subject.getTableGenerator(); - } - }; - } - - private GeneratorBuilder<TableGenerator> buildTableGeneratorBuilder(final PropertyValueModel<GeneratorContainer> generatorHolder) { - return new GeneratorBuilder<TableGenerator>() { - public TableGenerator addGenerator() { - return generatorHolder.getValue().addTableGenerator(); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildTableGeneratorBooleanHolder(PropertyValueModel<GeneratorContainer> generatorHolder) { - return new PropertyAspectAdapter<GeneratorContainer, Boolean>(generatorHolder, GeneratorContainer.TABLE_GENERATOR_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getTableGenerator() != null); - } - - @Override - protected void setValue_(Boolean value) { - - if (value.booleanValue() && (this.subject.getTableGenerator() == null)) { - - TableGenerator tableGenerator = this.subject.addTableGenerator(); - GeneratedValue generatedValue = getSubject().getGeneratedValue(); - - if ((generatedValue != null) && - (generatedValue.getGenerator() != null)) - { - tableGenerator.setName(generatedValue.getGenerator()); - } - } - else if (!value.booleanValue() && (this.subject.getTableGenerator() != null)) { - this.subject.removeTableGenerator(); - } - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/InverseJoinColumnInJoinTableDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/InverseJoinColumnInJoinTableDialog.java deleted file mode 100644 index 025924321f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/InverseJoinColumnInJoinTableDialog.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * - * @see InverseJoinColumnInJoinTableStateObject - * @see BaseJoinColumnDialogPane - * - * @version 2.0 - * @since 2.0 - */ -public class InverseJoinColumnInJoinTableDialog extends BaseJoinColumnDialog<InverseJoinColumnInJoinTableStateObject> { - - /** - * Creates a new <code>JoinColumnInJoinTableDialog</code>. - * - * @param parent The parent shell - * @param joinTable The owner of the join column to create or where it is - * located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public InverseJoinColumnInJoinTableDialog(Shell parent, - ReadOnlyJoinTable joinTable, - ReadOnlyJoinColumn joinColumn) { - - super(parent, joinTable, joinColumn); - } - - @Override - protected DialogPane<InverseJoinColumnInJoinTableStateObject> buildLayout(Composite container) { - return new JoinColumnDialogPane<InverseJoinColumnInJoinTableStateObject>( - getSubjectHolder(), - container - ) - - { - @Override - protected boolean isTableEditable() { - return false; - } - }; - } - - @Override - protected InverseJoinColumnInJoinTableStateObject buildStateObject() { - return new InverseJoinColumnInJoinTableStateObject( - getOwner(), - getJoinColumn() - ); - } - - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } - - @Override - protected JoinTable getOwner() { - return (JoinTable) super.getOwner(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/InverseJoinColumnInJoinTableStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/InverseJoinColumnInJoinTableStateObject.java deleted file mode 100644 index 0b8d288e83..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/InverseJoinColumnInJoinTableStateObject.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinTable; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.db.Table; - -/** - * The state object used to create or edit a primary key join column on a join - * table. - * - * @see JoinColumn - * @see JoinTable - * @see InverseJoinColumnInJoinTableDialog - * - * @version 2.3 - * @since 2.0 - */ -public class InverseJoinColumnInJoinTableStateObject - extends JoinColumnStateObject -{ - /** - * Creates a new <code>JoinColumnInJoinTableStateObject</code>. - * - * @param joinTable - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public InverseJoinColumnInJoinTableStateObject( - JoinTable joinTable, - JoinColumn joinColumn) { - super(joinTable, joinColumn); - } - - - @Override - public JoinTable getOwner() { - return (JoinTable) super.getOwner(); - } - - private RelationshipMapping getRelationshipMapping() { - return getOwner().getRelationshipMapping(); - } - - @Override - public String getDefaultTable() { - return null; - } - - @Override - public Table getNameTable() { - return getOwner().getDbTable(); - } - - @Override - public Table getReferencedNameTable() { - RelationshipMapping relationshipMapping = getRelationshipMapping(); - if (relationshipMapping == null) { - return null; - } - Entity targetEntity = relationshipMapping.getResolvedTargetEntity(); - if (targetEntity == null) { - return null; - } - return targetEntity.getPrimaryDbTable(); - } - - @Override - protected String getInitialTable() { - return getOwner().getName(); - } - - @Override - protected boolean isTableEditable() { - return false; - } - - @Override - public ListIterator<String> tables() { - return new SingleElementListIterator<String>(getInitialTable()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnDialog.java deleted file mode 100644 index 57109bf588..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnDialog.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * The abstract definition of the dialog used to edit an <code>IJoinColumn</code>. - * - * @see JoinColumn - * @see JoinColumnStateObject - * @see JoinColumnDialogPane - * - * @version 2.0 - * @since 2.0 - */ -public abstract class JoinColumnDialog<T extends JoinColumnStateObject> - extends BaseJoinColumnDialog<T> -{ - - /** - * Creates a new <code>AbstractJoinColumnDialog</code>. - * - * @param parent The parent shell - * @param owner The owner of the join column to create or where it is located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public JoinColumnDialog(Shell parent, Object owner, ReadOnlyJoinColumn joinColumn) { - super(parent, owner, joinColumn); - } - - @Override - protected DialogPane<?> buildLayout(Composite container) { - return new JoinColumnDialogPane<T>(getSubjectHolder(), container); - } - - @Override - public ReadOnlyJoinColumn getJoinColumn() { - return (ReadOnlyJoinColumn) super.getJoinColumn(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnDialogPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnDialogPane.java deleted file mode 100644 index afd6199f1c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnDialogPane.java +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | BaseJoinColumnDialogPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | x Insertable | - * | | - * | x Nullable | - * | | - * | x Unique | - * | | - * | x Updatable | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see JoinColumnStateObject - * @see JoinColumnDialog - The parent container - * - * @version 2.0 - * @since 1.0 - */ -public class JoinColumnDialogPane<T extends JoinColumnStateObject> extends BaseJoinColumnDialogPane<T> -{ - /** - * Creates a new <code>JoinColumnDialogPane</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public JoinColumnDialogPane(PropertyValueModel<? extends T> subjectHolder, - Composite parent) - { - super(subjectHolder, parent); - } - - private WritablePropertyValueModel<Boolean> buildInsertableHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), JoinColumnStateObject.INSERTABLE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getInsertable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setInsertable(value); - } - }; - } - - private PropertyValueModel<String> buildInsertableStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultInsertableHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.JoinColumnDialogPane_insertableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.JoinColumnDialogPane_insertable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultInsertableHolder() { - return new PropertyAspectAdapter<T, Boolean>( - getSubjectHolder(), - JoinColumnStateObject.INSERTABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getInsertable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultInsertable()); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildNullableHolder() { - return new PropertyAspectAdapter<T, Boolean>( - getSubjectHolder(), - JoinColumnStateObject.NULLABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getNullable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setNullable(value); - } - }; - } - - private PropertyValueModel<String> buildNullableStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultNullableHolder()) { - - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.JoinColumnDialogPane_nullableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.JoinColumnDialogPane_nullable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultNullableHolder() { - return new PropertyAspectAdapter<T, Boolean>( - getSubjectHolder(), - JoinColumnStateObject.NULLABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getNullable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultNullable()); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildUniqueHolder() { - return new PropertyAspectAdapter<T, Boolean>( - getSubjectHolder(), - JoinColumnStateObject.UNIQUE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getUnique(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setUnique(value); - } - }; - } - - private PropertyValueModel<String> buildUniqueStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultUniqueHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.JoinColumnDialogPane_uniqueWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.JoinColumnDialogPane_unique; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultUniqueHolder() { - return new PropertyAspectAdapter<T, Boolean>( - getSubjectHolder(), - JoinColumnStateObject.UNIQUE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getUnique() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultUnique()); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildUpdatableHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), JoinColumnStateObject.UPDATABLE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getUpdatable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setUpdatable(value); - } - }; - } - - private PropertyValueModel<String> buildUpdatableStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultUpdatableHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.JoinColumnDialogPane_updatableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.JoinColumnDialogPane_updatable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultUpdatableHolder() { - return new PropertyAspectAdapter<T, Boolean>( - getSubjectHolder(), - JoinColumnStateObject.UPDATABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getUpdatable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultUpdatable()); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - super.initializeLayout(container); - - // Insertable tri-state check box - addTriStateCheckBoxWithDefault( - addSubPane(container, 4), - JptUiDetailsMessages.JoinColumnDialogPane_insertable, - buildInsertableHolder(), - buildInsertableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_INSERTABLE - ); - - // Updatable tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.JoinColumnDialogPane_updatable, - buildUpdatableHolder(), - buildUpdatableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_UPDATABLE - ); - - // Unique tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_unique, - buildUniqueHolder(), - buildUniqueStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_UNIQUE - ); - - // Nullable tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_nullable, - buildNullableHolder(), - buildNullableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_NULLABLE - ); - } - - /* - * (non-Javadoc) - */ - @Override - protected boolean isTableEditable() { - return true; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInJoiningStrategyDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInJoiningStrategyDialog.java deleted file mode 100644 index 24d6fd8e78..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInJoiningStrategyDialog.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.swt.widgets.Shell; - -/** - * This dialog is used to either create or edit a joing column that is located - * on a relational mapping. - * - * @see JoinColumn - * @see JoinColumnRelationshipStrategy - * @see JoinColumnInJoiningStrategyStateObject - * @see JoinColumnDialogPane - * - * @version 2.0 - * @since 2.0 - */ -public class JoinColumnInJoiningStrategyDialog - extends JoinColumnDialog<JoinColumnInJoiningStrategyStateObject> -{ - /** - * Creates a new <code>AbstractJoinColumnDialog</code>. - * - * @param parent The parent shell - * @param relationshipMapping The owner of the join column to edit or to - * create - * @param joinColumn The join column to edit or <code>null</code> if this is - * used to create a new one - */ - JoinColumnInJoiningStrategyDialog( - Shell parent, - ReadOnlyJoinColumnRelationshipStrategy joinColumnOwner, - ReadOnlyJoinColumn joinColumn) { - - super(parent, joinColumnOwner, joinColumn); - } - - @Override - protected JoinColumnInJoiningStrategyStateObject buildStateObject() { - return new JoinColumnInJoiningStrategyStateObject( - getOwner(), - getJoinColumn() - ); - } - - @Override - protected JoinColumnRelationshipStrategy getOwner() { - return (JoinColumnRelationshipStrategy) super.getOwner(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInJoiningStrategyStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInJoiningStrategyStateObject.java deleted file mode 100644 index 2ff745f0f3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInJoiningStrategyStateObject.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Table; - -/** - * The state object used to create or edit a primary key join column on a - * relationship mapping. - * - * @see JoinColumn - * @see JoinColumnRelationshipStrategy - * @see JoinColumnInJoiningStrategyDialog - * - * @version 2.3 - * @since 2.0 - */ -public class JoinColumnInJoiningStrategyStateObject - extends JoinColumnStateObject -{ - /** - * Creates a new <code>JoinColumnInJoiningStrategyStateObject</code>. - * - * @param joiningStrategy The owner of the join column to create - * @param joinColumn The join column to edit or <code>null</code> if this is - * used to create a new one - */ - public JoinColumnInJoiningStrategyStateObject( - ReadOnlyJoinColumnRelationshipStrategy joiningStrategy, - ReadOnlyJoinColumn joinColumn) { - super(joiningStrategy, joinColumn); - } - - - @Override - public JoinColumnRelationshipStrategy getOwner() { - return (JoinColumnRelationshipStrategy) super.getOwner(); - } - - @Override - public ListIterator<String> tables() { - Schema schema = getDbSchema(); - return schema == null ? super.tables() : CollectionTools.list(schema.getSortedTableIdentifiers()).listIterator(); - } - - protected Schema getDbSchema() { - TypeMapping typeMapping = getRelationshipSource(); - return typeMapping == null ? null : typeMapping.getDbSchema(); - } - - protected TypeMapping getRelationshipSource() { - return getOwner().getRelationshipSource(); - } - - protected TypeMapping getRelationshipTarget() { - return getOwner().getRelationshipTarget(); - } - - @Override - public String getDefaultTable() { - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.getDefaultTable(); - } - TypeMapping typeMapping = getRelationshipSource(); - return typeMapping == null ? null : typeMapping.getPrimaryTableName(); - } - - @Override - public Table getNameTable() { - TypeMapping typeMapping = getRelationshipSource(); - return typeMapping == null ? null : typeMapping.getPrimaryDbTable(); - } - - @Override - public Table getReferencedNameTable() { - TypeMapping relationshipTarget = getRelationshipTarget(); - return relationshipTarget == null ? null : relationshipTarget.getPrimaryDbTable(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInReferenceTableDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInReferenceTableDialog.java deleted file mode 100644 index 291b5d8a92..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInReferenceTableDialog.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyReferenceTable; -import org.eclipse.jpt.jpa.core.context.ReferenceTable; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * This dialog is used to either create or edit a join column that is located - * on a join table. - * - * @see JoinColumn - * @see JoinTable - * @see JoinColumnInReferenceTableStateObject - * @see BaseJoinColumnDialogPane - * - * @version 2.0 - * @since 1.0 - */ -public class JoinColumnInReferenceTableDialog extends BaseJoinColumnDialog<JoinColumnInReferenceTableStateObject> { - - /** - * Creates a new <code>JoinColumnInReferenceTableDialog</code>. - * - * @param parent The parent shell - * @param joinTable The parent of the join column to edit or to create - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public JoinColumnInReferenceTableDialog(Shell parent, - ReadOnlyReferenceTable referenceTable, - ReadOnlyJoinColumn joinColumn) { - - super(parent, referenceTable, joinColumn); - } - - @Override - protected DialogPane<JoinColumnInReferenceTableStateObject> buildLayout(Composite container) { - return new JoinColumnDialogPane<JoinColumnInReferenceTableStateObject>( - getSubjectHolder(), - container - ) { - @Override - protected boolean isTableEditable() { - return false; - } - }; - } - - @Override - protected JoinColumnInReferenceTableStateObject buildStateObject() { - return new JoinColumnInReferenceTableStateObject( - getOwner(), - getJoinColumn() - ); - } - - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } - - @Override - protected ReferenceTable getOwner() { - return (ReferenceTable) super.getOwner(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInReferenceTableStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInReferenceTableStateObject.java deleted file mode 100644 index a3bdb624a8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnInReferenceTableStateObject.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinTable; -import org.eclipse.jpt.jpa.core.context.ReferenceTable; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.db.Table; - -/** - * The state object used to create or edit a primary key join column on a - * joint table. - * - * @see JoinColumn - * @see JoinTable - * @see InverseJoinColumnDialog - * @see InverseJoinColumnDialogPane - * @see JoinColumnInReferenceTableDialog - * - * @version 2.0 - * @since 2.0 - */ -public class JoinColumnInReferenceTableStateObject - extends JoinColumnStateObject -{ - /** - * Creates a new <code>JoinColumnInJoinTableStateObject</code>. - * - * @param joinTable The owner of the join column to create or to edit - * @param joinColumn The join column to edit - */ - public JoinColumnInReferenceTableStateObject( - ReferenceTable referenceTable, - JoinColumn joinColumn) { - super(referenceTable, joinColumn); - } - - - @Override - public ReferenceTable getOwner() { - return (ReferenceTable) super.getOwner(); - } - - private TypeMapping getTypeMapping() { - return getOwner().getPersistentAttribute().getOwningTypeMapping(); - } - - @Override - public String getDefaultTable() { - return null; - } - - @Override - public Table getNameTable() { - return getOwner().getDbTable(); - } - - @Override - public Table getReferencedNameTable() { - return getTypeMapping().getPrimaryDbTable(); - } - - @Override - protected String getInitialTable() { - return getOwner().getName(); - } - - @Override - protected boolean isTableEditable() { - return false; - } - - @Override - public ListIterator<String> tables() { - return new SingleElementListIterator<String>(getInitialTable()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnJoiningStrategyPane.java deleted file mode 100644 index debfa6e73c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnJoiningStrategyPane.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Join columns __________________________________________________________ | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoiningStrategyJoinColumnsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see JoinColumnRelationship - * @see ReadOnlyJoinColumnRelationshipStrategy - * @see OneToOneJoiningStrategyPane - * @see ManyToOneJoiningStrategyPane - * - * @version 2.3 - * @since 2.1 - */ -public class JoinColumnJoiningStrategyPane - extends AbstractJoiningStrategyPane - <ReadOnlyJoinColumnRelationship, ReadOnlyJoinColumnRelationshipStrategy> -{ - private final boolean includeOverrideCheckBox; - - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox( - Pane<? extends ReadOnlyJoinColumnRelationship> parentPane, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, parent, true); - } - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithoutIncludeOverrideCheckBox( - Pane<? extends ReadOnlyJoinColumnRelationship> parentPane, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, parent, false); - } - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyJoinColumnRelationship> subjectHolder, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, subjectHolder, parent, true); - } - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithoutIncludeOverrideCheckBox( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyJoinColumnRelationship> subjectHolder, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, subjectHolder, parent, false); - } - - - private JoinColumnJoiningStrategyPane( - Pane<? extends ReadOnlyJoinColumnRelationship> parentPane, - Composite parent, - boolean includeOverrideCheckBox) { - super(parentPane, parent); - this.includeOverrideCheckBox = includeOverrideCheckBox; - initializeLayout2(getControl()); - } - - private JoinColumnJoiningStrategyPane(Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyJoinColumnRelationship> subjectHolder, - Composite parent, - boolean includeOverrideCheckBox) { - - super(parentPane, subjectHolder, parent); - this.includeOverrideCheckBox = includeOverrideCheckBox; - initializeLayout2(getControl()); - } - - @Override - protected void initializeLayout(Composite container) { - //see initializeLayout2 - } - - protected void initializeLayout2(Composite container) { - super.initializeLayout(container); - //just call super, we are delaying the initializeLayout because of the includeOverrideCheckBox boolean - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - PropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy> joiningStrategyHolder = this.buildJoinColumnJoiningStrategyHolder(); - - return this.includeOverrideCheckBox ? - new JoiningStrategyJoinColumnsWithOverrideOptionComposite(this, joiningStrategyHolder, parent).getControl() : - new JoiningStrategyJoinColumnsComposite(this, joiningStrategyHolder, parent).getControl(); - } - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return buildUsesJoinColumnJoiningStrategyHolder(getSubjectHolder()); - } - - protected PropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy> buildJoinColumnJoiningStrategyHolder() { - return new PropertyAspectAdapter - <ReadOnlyJoinColumnRelationship, ReadOnlyJoinColumnRelationshipStrategy>( - getSubjectHolder()) { - @Override - protected ReadOnlyJoinColumnRelationshipStrategy buildValue_() { - return this.subject.getJoinColumnStrategy(); - } - }; - } - - public static WritablePropertyValueModel<Boolean> buildUsesJoinColumnJoiningStrategyHolder(PropertyValueModel<? extends ReadOnlyJoinColumnRelationship> subjectHolder) { - return new PropertyAspectAdapter<ReadOnlyJoinColumnRelationship, Boolean>( - subjectHolder, ReadOnlyRelationship.STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return Boolean.valueOf(this.buildBooleanValue()); - } - - protected boolean buildBooleanValue() { - return (this.subject != null) && this.subject.strategyIsJoinColumn(); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - ((JoinColumnRelationship) this.subject).setStrategyToJoinColumn(); - } - //value == FALSE - selection of another radio button causes this strategy to get unset - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnStateObject.java deleted file mode 100644 index 0627a4072b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnStateObject.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.jpa.core.context.BaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; - -/** - * The state object used to edit a <code>JoinColumn</code>. - * - * @see JoinColumn - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public abstract class JoinColumnStateObject - extends BaseJoinColumnStateObject -{ - private Boolean insertable; - private Boolean nullable; - private Boolean unique; - private Boolean updatable; - - public static final String INSERTABLE_PROPERTY = "insertable"; - public static final String NULLABLE_PROPERTY = "nullable"; - public static final String UNIQUE_PROPERTY = "unique"; - public static final String UPDATABLE_PROPERTY = "updatable"; - - /** - * Creates a new <code>JoinColumnStateObject</code>. - * - * @param owner The owner of the join column to create or where it is located - * @param joinColumn The join column to edit - */ - public JoinColumnStateObject(Object owner, ReadOnlyJoinColumn joinColumn) { - super(owner, joinColumn); - } - - public boolean isDefaultInsertable() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultInsertable(); - } - - return ReadOnlyBaseColumn.DEFAULT_INSERTABLE; - } - - public boolean isDefaultNullable() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultNullable(); - } - - return ReadOnlyBaseColumn.DEFAULT_NULLABLE; - } - - public boolean isDefaultUnique() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultUnique(); - } - - return ReadOnlyBaseColumn.DEFAULT_UNIQUE; - } - - public boolean isDefaultUpdatable() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultUpdatable(); - } - - return ReadOnlyBaseColumn.DEFAULT_UPDATABLE; - } - - public Boolean getInsertable() { - return this.insertable; - } - - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } - - public Boolean getNullable() { - return this.nullable; - } - - public Boolean getUnique() { - return this.unique; - } - - public Boolean getUpdatable() { - return this.updatable; - } - - @Override - protected void initialize(Object owner, ReadOnlyBaseJoinColumn baseJoinColumn) { - - super.initialize(owner, baseJoinColumn); - - if (baseJoinColumn != null) { - ReadOnlyJoinColumn joinColumn = (ReadOnlyJoinColumn) baseJoinColumn; - - this.insertable = joinColumn.getSpecifiedInsertable(); - this.nullable = joinColumn.getSpecifiedNullable(); - this.unique = joinColumn.getSpecifiedUnique(); - this.updatable = joinColumn.getSpecifiedUpdatable(); - } - } - - @Override - protected String getInitialTable() { - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn == null) { - return null; - } - - return joinColumn.getSpecifiedTable(); - } - - protected boolean isTableEditable() { - return true; - } - - public void setInsertable(Boolean insertable) { - Boolean oldInsertable = this.insertable; - this.insertable = insertable; - firePropertyChanged(INSERTABLE_PROPERTY, oldInsertable, insertable); - } - - public void setNullable(Boolean nullable) { - Boolean oldNullable = this.nullable; - this.nullable = nullable; - firePropertyChanged(NULLABLE_PROPERTY, oldNullable, nullable); - } - - public void setUnique(Boolean unique) { - Boolean oldUnique = this.unique; - this.unique = unique; - firePropertyChanged(UNIQUE_PROPERTY, oldUnique, unique); - } - - public void setUpdatable(Boolean updatable) { - Boolean oldUpdatable = this.updatable; - this.updatable = updatable; - firePropertyChanged(UPDATABLE_PROPERTY, oldUpdatable, updatable); - } - - @Override - public ListIterator<String> tables() { - return EmptyListIterator.instance(); - } - - @Override - public void updateJoinColumn(BaseJoinColumn abstractJoinColumn) { - - super.updateJoinColumn(abstractJoinColumn); - - JoinColumn joinColumn = (JoinColumn) abstractJoinColumn; - - // Table - if (isTableEditable()) { - String table = getTable(); - - if (valuesAreDifferent(table, joinColumn.getSpecifiedTable())) { - joinColumn.setSpecifiedTable(table); - } - } - - // Insertable - if (joinColumn.getSpecifiedInsertable() != this.insertable){ - joinColumn.setSpecifiedInsertable(this.insertable); - } - - // Updatable - if (joinColumn.getSpecifiedUpdatable() != this.updatable){ - joinColumn.setSpecifiedUpdatable(this.updatable); - } - - // Unique - if (joinColumn.getSpecifiedUnique() != this.unique){ - joinColumn.setSpecifiedUnique(this.unique); - } - - // Nullable - if (joinColumn.getSpecifiedNullable() != this.nullable){ - joinColumn.setSpecifiedNullable(this.nullable); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnsComposite.java deleted file mode 100644 index 2797dd324e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinColumnsComposite.java +++ /dev/null @@ -1,329 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.ListIterator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.AbstractAdapter; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see JoiningStrategyJoinColumnsComposite - A container of this pane - * @see JoinTableComposite - A container of this pane - * @see EntityOverridesComposite - A container of this pane - * - * @version 3.0 - * @since 2.0 - */ -public class JoinColumnsComposite<T extends JpaNode> extends Pane<T> -{ - /** - * The editor used to perform the common behaviors defined in the list pane. - */ - JoinColumnsEditor<T> joinColumnsEditor; - - private AddRemoveListPane<T> listPane; - - /** - * Creates a new <code>JoinColumnsComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - * @param joinColumnsEditor The editor used to perform the common behaviors - * defined in the list pane - */ - public JoinColumnsComposite(Pane<? extends T> parentPane, - Composite parent, - JoinColumnsEditor<T> joinColumnsEditor) { - - super(parentPane, parent); - this.joinColumnsEditor = joinColumnsEditor; - initializeLayout2(); - } - - /** - * Creates a new <code>JoinColumnsComposite</code>. - * - * @param parentPane The parent controller of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param joinColumnsEditor The editor used to perform the common behaviors - * defined in the list pane - */ - public JoinColumnsComposite(Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - JoinColumnsEditor<T> joinColumnsEditor, - boolean automaticallyAlignWidgets) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets); - this.joinColumnsEditor = joinColumnsEditor; - initializeLayout2(); - } - - /** - * Creates a new <code>JoinColumnsComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JoinColumnsComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory, - JoinColumnsEditor<T> joinColumnsEditor) { - - super(subjectHolder, parent, widgetFactory); - this.joinColumnsEditor = joinColumnsEditor; - initializeLayout2(); - } - - @Override - protected void initializeLayout(Composite container) { - //see intiailizeLayout2() - } - - private void initializeLayout2() { - this.listPane = new AddRemoveListPane<T>( - this, - getControl(), - buildJoinColumnsAdapter(), - buildJoinColumnsListModel(), - buildSelectedJoinColumnHolder(), - buildJoinColumnsListLabelProvider(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS, - false - ); - } - - private WritablePropertyValueModel<JoinColumn> buildSelectedJoinColumnHolder() { - return new SimplePropertyValueModel<JoinColumn>(); - } - - String buildJoinColumnLabel(ReadOnlyJoinColumn joinColumn) { - - if (joinColumn.isDefault()) { - return NLS.bind( - JptUiDetailsMessages.JoinColumnsComposite_mappingBetweenTwoParamsDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - if (joinColumn.getSpecifiedName() == null) { - - if (joinColumn.getSpecifiedReferencedColumnName() == null) { - return NLS.bind( - JptUiDetailsMessages.JoinColumnsComposite_mappingBetweenTwoParamsBothDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - return NLS.bind( - JptUiDetailsMessages.JoinColumnsComposite_mappingBetweenTwoParamsFirstDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - if (joinColumn.getSpecifiedReferencedColumnName() == null) { - return NLS.bind( - JptUiDetailsMessages.JoinColumnsComposite_mappingBetweenTwoParamsSecDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - return NLS.bind( - JptUiDetailsMessages.JoinColumnsComposite_mappingBetweenTwoParams, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - private Adapter buildJoinColumnsAdapter() { - return new AbstractAdapter() { - - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - JoinColumnsComposite.this.joinColumnsEditor.addJoinColumn(getSubject()); - } - - @Override - public boolean hasOptionalButton() { - return true; - } - - @Override - public String optionalButtonText() { - return JptUiDetailsMessages.JoinColumnsComposite_edit; - } - - @Override - public void optionOnSelection(ObjectListSelectionModel listSelectionModel) { - JoinColumn joinColumn = (JoinColumn) listSelectionModel.selectedValue(); - JoinColumnsComposite.this.joinColumnsEditor.editJoinColumn(getSubject(), joinColumn); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - JoinColumnsComposite.this.joinColumnsEditor.removeJoinColumns(getSubject(), listSelectionModel.selectedIndices()); - } - }; - } - - private ListValueModel<ReadOnlyJoinColumn> buildJoinColumnsListModel() { - return new ItemPropertyListValueModelAdapter<ReadOnlyJoinColumn>(buildJoinColumnsListHolder(), - ReadOnlyNamedColumn.SPECIFIED_NAME_PROPERTY, - ReadOnlyNamedColumn.DEFAULT_NAME_PROPERTY, - ReadOnlyBaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, - ReadOnlyBaseJoinColumn.DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY); - } - - private ListValueModel<ReadOnlyJoinColumn> buildJoinColumnsListHolder() { - java.util.List<ListValueModel<ReadOnlyJoinColumn>> list = new ArrayList<ListValueModel<ReadOnlyJoinColumn>>(); - list.add(buildSpecifiedJoinColumnsListHolder()); - list.add(buildDefaultJoinColumnListHolder()); - return new CompositeListValueModel<ListValueModel<ReadOnlyJoinColumn>, ReadOnlyJoinColumn>(list); - } - - private ListValueModel<ReadOnlyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<T, ReadOnlyJoinColumn>(getSubjectHolder(), this.joinColumnsEditor.getSpecifiedJoinColumnsListPropertyName()) { - @Override - protected ListIterator<ReadOnlyJoinColumn> listIterator_() { - return JoinColumnsComposite.this.joinColumnsEditor.specifiedJoinColumns(this.subject); - } - - @Override - protected int size_() { - return JoinColumnsComposite.this.joinColumnsEditor.specifiedJoinColumnsSize(this.subject); - } - }; - } - - - private ListValueModel<ReadOnlyJoinColumn> buildDefaultJoinColumnListHolder() { - return new PropertyListValueModelAdapter<ReadOnlyJoinColumn>(buildDefaultJoinColumnHolder()); - - } - - private PropertyValueModel<ReadOnlyJoinColumn> buildDefaultJoinColumnHolder() { - return new PropertyAspectAdapter<T, ReadOnlyJoinColumn>(getSubjectHolder(), this.joinColumnsEditor.getDefaultPropertyName()) { - @Override - protected ReadOnlyJoinColumn buildValue_() { - return JoinColumnsComposite.this.joinColumnsEditor.getDefaultJoinColumn(this.subject); - } - }; - } - - - private ILabelProvider buildJoinColumnsListLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - ReadOnlyJoinColumn joinColumn = (ReadOnlyJoinColumn) element; - - return buildJoinColumnLabel(joinColumn); - } - }; - } - - public void installJoinColumnsPaneEnabler(PropertyValueModel<Boolean> joinColumnsPaneEnablerHolder) { - new PaneEnabler(joinColumnsPaneEnablerHolder, this.listPane); - } - - public void setSelectedJoinColumn(JoinColumn joinColumn) { - this.listPane.setSelectedItem(joinColumn); - } - - /** - * The editor is used to complete the behavior of this pane. - */ - public static interface JoinColumnsEditor<T> { - - /** - * Add a join column to the given subject and return it - */ - void addJoinColumn(T subject); - - /** - * Edit the given join column, the Edit button was pressed - * while this join column was selected. - */ - void editJoinColumn(T subject, ReadOnlyJoinColumn joinColumn); - - /** - * Return whether the subject has specified join columns - */ - boolean hasSpecifiedJoinColumns(T subject); - - /** - * Return the spcified join columns from the given subject - */ - ListIterator<ReadOnlyJoinColumn> specifiedJoinColumns(T subject); - - /** - * Return the number of specified join columns on the given subject - */ - int specifiedJoinColumnsSize(T subject); - - /** - * Return the default join column from the given subject or null. - */ - ReadOnlyJoinColumn getDefaultJoinColumn(T subject); - - /** - * Return the property name of the specified join columns list - */ - String getSpecifiedJoinColumnsListPropertyName(); - - /** - * Return the property name of the specified join columns list - */ - String getDefaultPropertyName(); - - /** - * Remove the join columns at the specified indices from the subject - */ - void removeJoinColumns(T subject, int[] selectedIndices); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinTableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinTableComposite.java deleted file mode 100644 index 6ee91890a4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinTableComposite.java +++ /dev/null @@ -1,417 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.ValueListAdapter; -import org.eclipse.jpt.common.utility.model.event.StateChangeEvent; -import org.eclipse.jpt.common.utility.model.listener.StateChangeListener; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnsComposite.JoinColumnsEditor; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.TableCombo; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | --------------------------------------------------------------- | - * | Name: | |v| | - * | --------------------------------------------------------------- | - * | | - * | - Join Columns ---------------------------------------------------------- | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoinColumnsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * | | - * | - Inverse Join Columns -------------------------------------------------- | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoinColumnsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see JoinTable - * @see JoinTableJoiningStrategyPane - * @see JoinColumnsComposite - * - * @version 2.1 - * @since 1.0 - */ -public class JoinTableComposite - extends ReferenceTableComposite<ReadOnlyJoinTable> -{ - private Button overrideDefaultInverseJoinColumnsCheckBox; - - private JoinColumnsComposite<ReadOnlyJoinTable> inverseJoinColumnsComposite; - /** - * Creates a new <code>JoinTableComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public JoinTableComposite( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyJoinTable> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - /** - * Creates a new <code>JoinTableComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IJoinTable</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JoinTableComposite(PropertyValueModel<? extends ReadOnlyJoinTable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected boolean tableIsVirtual(ReadOnlyJoinTable joinTable) { - return joinTable.getParent().getRelationship().isVirtual(); - } - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = getGroupBoxMargin(); - - // Name widgets - TableCombo<ReadOnlyJoinTable> tableCombo = addTableCombo(container); - Composite tablePane = addPane(container, groupBoxMargin); - addLabeledComposite( - tablePane, - JptUiDetailsMessages.JoinTableComposite_name, - tableCombo.getControl(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_NAME - ); - - // schema widgets - SchemaCombo<ReadOnlyJoinTable> schemaCombo = addSchemaCombo(container); - - addLabeledComposite( - tablePane, - JptUiDetailsMessages.JoinTableComposite_schema, - schemaCombo.getControl(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_SCHEMA - ); - - // catalog widgets - CatalogCombo<ReadOnlyJoinTable> catalogCombo = addCatalogCombo(container); - - addLabeledComposite( - tablePane, - JptUiDetailsMessages.JoinTableComposite_catalog, - catalogCombo.getControl(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_CATALOG - ); - - // Join Columns group pane - Group joinColumnGroupPane = addTitledGroup( - container, - JptUiDetailsMessages.JoinTableComposite_joinColumn - ); - - // Override Default Join Columns check box - this.overrideDefaultJoinColumnsCheckBox = addCheckBox( - addSubPane(joinColumnGroupPane, 8), - JptUiDetailsMessages.JoinTableComposite_overrideDefaultJoinColumns, - buildOverrideDefaultJoinColumnHolder(), - null - ); - - this.joinColumnsComposite = new JoinColumnsComposite<ReadOnlyJoinTable>( - this, - joinColumnGroupPane, - buildJoinColumnsEditor() - ); - - installJoinColumnsPaneEnabler(this.joinColumnsComposite); - - // Inverse Join Columns group pane - Group inverseJoinColumnGroupPane = addTitledGroup( - container, - JptUiDetailsMessages.JoinTableComposite_inverseJoinColumn - ); - - // Override Default Inverse Join Columns check box - this.overrideDefaultInverseJoinColumnsCheckBox = addCheckBox( - addSubPane(inverseJoinColumnGroupPane, 8), - JptUiDetailsMessages.JoinTableComposite_overrideDefaultInverseJoinColumns, - buildOverrideDefaultInverseJoinColumnHolder(), - null - ); - - this.inverseJoinColumnsComposite = new JoinColumnsComposite<ReadOnlyJoinTable>( - this, - inverseJoinColumnGroupPane, - buildInverseJoinColumnsEditor() - ); - - installInverseJoinColumnsPaneEnabler(this.inverseJoinColumnsComposite); - } - - private void installInverseJoinColumnsPaneEnabler(JoinColumnsComposite<ReadOnlyJoinTable> pane) { - pane.installJoinColumnsPaneEnabler(new InverseJoinColumnPaneEnablerHolder()); - } - - void addInverseJoinColumn(ReadOnlyJoinTable joinTable) { - - InverseJoinColumnInJoinTableDialog dialog = - new InverseJoinColumnInJoinTableDialog(getShell(), joinTable, null); - - dialog.openDialog(buildAddInverseJoinColumnPostExecution()); - } - - void addInverseJoinColumnFromDialog(InverseJoinColumnInJoinTableStateObject stateObject) { - - JoinTable subject = (JoinTable) getSubject(); - int index = subject.specifiedInverseJoinColumnsSize(); - - JoinColumn joinColumn = subject.addSpecifiedInverseJoinColumn(index); - stateObject.updateJoinColumn(joinColumn); - this.setSelectedInverseJoinColumn(joinColumn); - } - - private void setSelectedInverseJoinColumn(JoinColumn joinColumn) { - this.inverseJoinColumnsComposite.setSelectedJoinColumn(joinColumn); - } - - private PostExecution<InverseJoinColumnInJoinTableDialog> buildAddInverseJoinColumnPostExecution() { - return new PostExecution<InverseJoinColumnInJoinTableDialog>() { - public void execute(InverseJoinColumnInJoinTableDialog dialog) { - if (dialog.wasConfirmed()) { - addInverseJoinColumnFromDialog(dialog.getSubject()); - } - } - }; - } - - private PostExecution<InverseJoinColumnInJoinTableDialog> buildEditInverseJoinColumnPostExecution() { - return new PostExecution<InverseJoinColumnInJoinTableDialog>() { - public void execute(InverseJoinColumnInJoinTableDialog dialog) { - if (dialog.wasConfirmed()) { - editInverseJoinColumn(dialog.getSubject()); - } - } - }; - } - - - private InverseJoinColumnsProvider buildInverseJoinColumnsEditor() { - return new InverseJoinColumnsProvider(); - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultInverseJoinColumnHolder() { - return new OverrideDefaultInverseJoinColumnHolder(); - } - - ListValueModel<ReadOnlyJoinColumn> buildSpecifiedInverseJoinColumnsListHolder() { - return new ListAspectAdapter<ReadOnlyJoinTable, ReadOnlyJoinColumn>(getSubjectHolder(), ReadOnlyJoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<ReadOnlyJoinColumn> listIterator_() { - return new SuperListIteratorWrapper<ReadOnlyJoinColumn>(this.subject.specifiedInverseJoinColumns()); - } - - @Override - protected int size_() { - return this.subject.specifiedInverseJoinColumnsSize(); - } - }; - } - - - void editInverseJoinColumn(InverseJoinColumnInJoinTableStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - void editInverseJoinColumn(ReadOnlyJoinColumn joinColumn) { - - InverseJoinColumnInJoinTableDialog dialog = - new InverseJoinColumnInJoinTableDialog(getShell(), getSubject(), joinColumn); - - dialog.openDialog(buildEditInverseJoinColumnPostExecution()); - } - - void updateInverseJoinColumns() { - if (this.isPopulating()) { - return; - } - - JoinTable joinTable = (JoinTable) this.getSubject(); - if (joinTable == null) { - return; - } - - boolean selected = this.overrideDefaultInverseJoinColumnsCheckBox.getSelection(); - this.setPopulating(true); - - try { - if (selected) { - joinTable.convertDefaultToSpecifiedInverseJoinColumn(); - setSelectedInverseJoinColumn(joinTable.specifiedInverseJoinColumns().next()); - } else { - joinTable.clearSpecifiedInverseJoinColumns(); - } - } finally { - this.setPopulating(false); - } - } - - - - class InverseJoinColumnsProvider implements JoinColumnsEditor<ReadOnlyJoinTable> { - - public void addJoinColumn(ReadOnlyJoinTable subject) { - JoinTableComposite.this.addInverseJoinColumn(subject); - } - - public ReadOnlyJoinColumn getDefaultJoinColumn(ReadOnlyJoinTable subject) { - return subject.getDefaultInverseJoinColumn(); - } - - public String getDefaultPropertyName() { - return ReadOnlyJoinTable.DEFAULT_INVERSE_JOIN_COLUMN; - } - - public void editJoinColumn(ReadOnlyJoinTable subject, ReadOnlyJoinColumn joinColumn) { - JoinTableComposite.this.editInverseJoinColumn(joinColumn); - } - - public boolean hasSpecifiedJoinColumns(ReadOnlyJoinTable subject) { - return subject.hasSpecifiedInverseJoinColumns(); - } - - public void removeJoinColumns(ReadOnlyJoinTable subject, int[] selectedIndices) { - for (int index = selectedIndices.length; index-- > 0; ) { - ((JoinTable) subject).removeSpecifiedInverseJoinColumn(selectedIndices[index]); - } - } - - public ListIterator<ReadOnlyJoinColumn> specifiedJoinColumns(ReadOnlyJoinTable subject) { - return new SuperListIteratorWrapper<ReadOnlyJoinColumn>(subject.specifiedInverseJoinColumns()); - } - - public int specifiedJoinColumnsSize(ReadOnlyJoinTable subject) { - return subject.specifiedInverseJoinColumnsSize(); - } - - public String getSpecifiedJoinColumnsListPropertyName() { - return ReadOnlyJoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST; - } - } - - private class OverrideDefaultInverseJoinColumnHolder extends ListPropertyValueModelAdapter<Boolean> - implements WritablePropertyValueModel<Boolean> { - - public OverrideDefaultInverseJoinColumnHolder() { - super(buildSpecifiedInverseJoinColumnsListHolder()); - } - - @Override - protected Boolean buildValue() { - return Boolean.valueOf(this.listHolder.size() > 0); - } - - public void setValue(Boolean value) { - updateInverseJoinColumns(); - } - } - - - private class InverseJoinColumnPaneEnablerHolder - extends CachingTransformationPropertyValueModel<ReadOnlyJoinTable, Boolean> - { - private StateChangeListener stateChangeListener; - - - public InverseJoinColumnPaneEnablerHolder() { - super( - new ValueListAdapter<ReadOnlyJoinTable>( - new ReadOnlyWritablePropertyValueModelWrapper<ReadOnlyJoinTable>(getSubjectHolder()), - ReadOnlyJoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST)); - this.stateChangeListener = buildStateChangeListener(); - } - - - private StateChangeListener buildStateChangeListener() { - return new StateChangeListener() { - public void stateChanged(StateChangeEvent event) { - valueStateChanged(); - } - }; - } - - void valueStateChanged() { - Object oldValue = this.cachedValue; - Object newValue = transformNew(this.valueHolder.getValue()); - firePropertyChanged(VALUE, oldValue, newValue); - } - - @Override - protected Boolean transform(ReadOnlyJoinTable value) { - return (value == null) ? Boolean.FALSE : super.transform(value); - } - - @Override - protected Boolean transform_(ReadOnlyJoinTable value) { - boolean virtual = JoinTableComposite.this.tableIsVirtual(value); - return Boolean.valueOf(! virtual && value.specifiedInverseJoinColumnsSize() > 0); - } - - @Override - protected void engageModel() { - super.engageModel(); - this.valueHolder.addStateChangeListener(this.stateChangeListener); - } - - @Override - protected void disengageModel() { - this.valueHolder.removeStateChangeListener(this.stateChangeListener); - super.disengageModel(); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinTableJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinTableJoiningStrategyPane.java deleted file mode 100644 index 28ec5e1098..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoinTableJoiningStrategyPane.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinTableRelationship; -import org.eclipse.jpt.jpa.core.context.JoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Join table ____________________________________________________________ | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoinTableComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link JoinTableRelationship} - * @see {@link JoinTableRelationshipStrategy} - * @see {@link ManyToOneJoiningStrategyPane} - * @see {@link ManyToManyJoiningStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class JoinTableJoiningStrategyPane - extends AbstractJoiningStrategyPane - <ReadOnlyJoinTableRelationship, ReadOnlyJoinTableRelationshipStrategy> -{ - public JoinTableJoiningStrategyPane( - Pane<? extends ReadOnlyJoinTableRelationship> parentPane, - Composite parent) { - super(parentPane, parent); - } - - public JoinTableJoiningStrategyPane(Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyJoinTableRelationship> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - return new JoinTableComposite(this, buildJoinTableHolder(), parent).getControl(); - } - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return buildUsesJoinTableJoiningStrategyHolder(getSubjectHolder()); - } - - protected PropertyValueModel<ReadOnlyJoinTableRelationshipStrategy> buildJoinTableJoiningStrategyHolder() { - return new PropertyAspectAdapter - <ReadOnlyJoinTableRelationship, ReadOnlyJoinTableRelationshipStrategy>( - getSubjectHolder()) { - @Override - protected ReadOnlyJoinTableRelationshipStrategy buildValue_() { - return this.subject.getJoinTableStrategy(); - } - }; - } - - protected PropertyValueModel<ReadOnlyJoinTable> buildJoinTableHolder() { - return new PropertyAspectAdapter<ReadOnlyJoinTableRelationshipStrategy, ReadOnlyJoinTable>( - this.buildJoinTableJoiningStrategyHolder(), ReadOnlyJoinTableRelationshipStrategy.JOIN_TABLE_PROPERTY) { - @Override - protected ReadOnlyJoinTable buildValue_() { - return this.subject.getJoinTable(); - } - }; - } - - public static WritablePropertyValueModel<Boolean> buildUsesJoinTableJoiningStrategyHolder(PropertyValueModel<? extends ReadOnlyJoinTableRelationship> subjectHolder) { - return new PropertyAspectAdapter<ReadOnlyJoinTableRelationship, Boolean>( - subjectHolder, ReadOnlyRelationship.STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return Boolean.valueOf(this.buildBooleanValue()); - } - - protected boolean buildBooleanValue() { - return (this.subject != null) && this.subject.strategyIsJoinTable(); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - ((JoinTableRelationship) this.subject).setStrategyToJoinTable(); - } - //value == FALSE - selection of another radio button causes this strategy to get unset - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsComposite.java deleted file mode 100644 index a23e0e293e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsComposite.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.ValueListAdapter; -import org.eclipse.jpt.common.utility.model.event.StateChangeEvent; -import org.eclipse.jpt.common.utility.model.listener.StateChangeListener; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnsComposite.JoinColumnsEditor; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * --------------------------------------------------------------------- - * | | - * | JoinColumnsComposite | - * | | - * --------------------------------------------------------------------- - * -------------------------------------------------------------------------</pre> - * - * @see JoinColumnRelationship - * @see JoinColumnRelationshipStrategy - * @see JoinColumnJoiningStrategyPane - * @see JoinColumnInJoiningStrategyDialog - * - * @version 3.0 - * @since 2.0 - */ -public class JoiningStrategyJoinColumnsComposite - extends Pane<ReadOnlyJoinColumnRelationshipStrategy> -{ - - private JoinColumnsComposite<ReadOnlyJoinColumnRelationshipStrategy> joinColumnsComposite; - - public JoiningStrategyJoinColumnsComposite( - Pane<?> parentPane, - PropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - this.joinColumnsComposite = new JoinColumnsComposite<ReadOnlyJoinColumnRelationshipStrategy>(this, container, buildJoinColumnsProvider()); - this.joinColumnsComposite.installJoinColumnsPaneEnabler(new JoinColumnPaneEnablerHolder()); - } - - private JoinColumnsEditor<ReadOnlyJoinColumnRelationshipStrategy> buildJoinColumnsProvider() { - return new JoinColumnsEditor<ReadOnlyJoinColumnRelationshipStrategy>() { - - public void addJoinColumn(ReadOnlyJoinColumnRelationshipStrategy subject) { - JoiningStrategyJoinColumnsComposite.this.addJoinColumn(subject); - } - - public boolean hasSpecifiedJoinColumns(ReadOnlyJoinColumnRelationshipStrategy subject) { - return subject.hasSpecifiedJoinColumns(); - } - - public void editJoinColumn(ReadOnlyJoinColumnRelationshipStrategy subject, ReadOnlyJoinColumn joinColumn) { - JoiningStrategyJoinColumnsComposite.this.editJoinColumn(subject, joinColumn); - } - - public ReadOnlyJoinColumn getDefaultJoinColumn(ReadOnlyJoinColumnRelationshipStrategy subject) { - return subject.getDefaultJoinColumn(); - } - - public String getDefaultPropertyName() { - return ReadOnlyJoinColumnRelationshipStrategy.DEFAULT_JOIN_COLUMN_PROPERTY; - } - - public String getSpecifiedJoinColumnsListPropertyName() { - return ReadOnlyJoinColumnRelationshipStrategy.SPECIFIED_JOIN_COLUMNS_LIST; - } - - public void removeJoinColumns(ReadOnlyJoinColumnRelationshipStrategy subject, int[] selectedIndices) { - for (int index = selectedIndices.length; --index >= 0; ) { - ((JoinColumnRelationshipStrategy) subject).removeSpecifiedJoinColumn(selectedIndices[index]); - } - } - - public ListIterator<ReadOnlyJoinColumn> specifiedJoinColumns(ReadOnlyJoinColumnRelationshipStrategy subject) { - return new SuperListIteratorWrapper<ReadOnlyJoinColumn>(subject.specifiedJoinColumns()); - } - - public int specifiedJoinColumnsSize(ReadOnlyJoinColumnRelationshipStrategy subject) { - return subject.specifiedJoinColumnsSize(); - } - }; - } - - void addJoinColumn(ReadOnlyJoinColumnRelationshipStrategy joiningStrategy) { - JoinColumnInJoiningStrategyDialog dialog = - new JoinColumnInJoiningStrategyDialog(getShell(), joiningStrategy, null); - dialog.openDialog(buildAddJoinColumnPostExecution()); - } - - private PostExecution<JoinColumnInJoiningStrategyDialog> buildAddJoinColumnPostExecution() { - return new PostExecution<JoinColumnInJoiningStrategyDialog>() { - public void execute(JoinColumnInJoiningStrategyDialog dialog) { - if (dialog.wasConfirmed()) { - addJoinColumn(dialog.getSubject()); - } - } - }; - } - - void addJoinColumn(JoinColumnInJoiningStrategyStateObject stateObject) { - JoinColumnRelationshipStrategy subject = (JoinColumnRelationshipStrategy) getSubject(); - JoinColumn joinColumn = subject.addSpecifiedJoinColumn(); - stateObject.updateJoinColumn(joinColumn); - this.setSelectedJoinColumn(joinColumn); - } - - public void setSelectedJoinColumn(JoinColumn joinColumn) { - this.joinColumnsComposite.setSelectedJoinColumn(joinColumn); - } - - void editJoinColumn(ReadOnlyJoinColumnRelationshipStrategy joiningStrategy, ReadOnlyJoinColumn joinColumn) { - JoinColumnInJoiningStrategyDialog dialog = - new JoinColumnInJoiningStrategyDialog(getShell(), joiningStrategy, joinColumn); - dialog.openDialog(buildEditJoinColumnPostExecution()); - } - - private PostExecution<JoinColumnInJoiningStrategyDialog> buildEditJoinColumnPostExecution() { - return new PostExecution<JoinColumnInJoiningStrategyDialog>() { - public void execute(JoinColumnInJoiningStrategyDialog dialog) { - if (dialog.wasConfirmed()) { - updateJoinColumn(dialog.getSubject()); - } - } - }; - } - - void updateJoinColumn(JoinColumnInJoiningStrategyStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - protected CachingTransformationPropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy, Boolean> buildJoinColumnsPaneEnabledHolder() { - return new CachingTransformationPropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy, Boolean>( - new ValueListAdapter<ReadOnlyJoinColumnRelationshipStrategy>( - new ReadOnlyWritablePropertyValueModelWrapper<ReadOnlyJoinColumnRelationshipStrategy>(getSubjectHolder()), - ReadOnlyJoinColumnRelationshipStrategy.SPECIFIED_JOIN_COLUMNS_LIST)) { - - @Override - protected Boolean transform(ReadOnlyJoinColumnRelationshipStrategy value) { - if (value == null) { - return Boolean.FALSE; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(ReadOnlyJoinColumnRelationshipStrategy value) { - boolean virtual = value.getRelationship().getMapping().getPersistentAttribute().isVirtual(); - return Boolean.valueOf(! virtual && value.specifiedJoinColumnsSize() > 0); - } - }; - - } - - - private class JoinColumnPaneEnablerHolder - extends CachingTransformationPropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy, Boolean> - { - private StateChangeListener stateChangeListener; - - - public JoinColumnPaneEnablerHolder() { - super( - new ValueListAdapter<ReadOnlyJoinColumnRelationshipStrategy>( - new ReadOnlyWritablePropertyValueModelWrapper<ReadOnlyJoinColumnRelationshipStrategy>(getSubjectHolder()), - ReadOnlyJoinColumnRelationshipStrategy.SPECIFIED_JOIN_COLUMNS_LIST)); - this.stateChangeListener = buildStateChangeListener(); - } - - - private StateChangeListener buildStateChangeListener() { - return new StateChangeListener() { - public void stateChanged(StateChangeEvent event) { - valueStateChanged(); - } - }; - } - - void valueStateChanged() { - Object oldValue = this.cachedValue; - Object newValue = transformNew(this.valueHolder.getValue()); - firePropertyChanged(VALUE, oldValue, newValue); - } - - @Override - protected Boolean transform(ReadOnlyJoinColumnRelationshipStrategy value) { - if (value == null) { - return Boolean.FALSE; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(ReadOnlyJoinColumnRelationshipStrategy value) { - boolean virtual = value.getRelationship().isVirtual(); - return Boolean.valueOf(! virtual && value.specifiedJoinColumnsSize() > 0); - } - - @Override - protected void engageModel() { - super.engageModel(); - this.valueHolder.addStateChangeListener(this.stateChangeListener); - } - - @Override - protected void disengageModel() { - this.valueHolder.removeStateChangeListener(this.stateChangeListener); - super.disengageModel(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java deleted file mode 100644 index 553f818029..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ------------------------------------------------------------------------- - * x Override Default - * --------------------------------------------------------------------- - * | | - * | JoiningStrategyJoinColumnsComposite | - * | | - * --------------------------------------------------------------------- - * -------------------------------------------------------------------------</pre> - * - * @see JoinColumnRelationship - * @see JoinColumnRelationshipStrategy - * @see JoinColumnJoiningStrategyPane - * @see JoinColumnInJoiningStrategyDialog - * - * @version 3.0 - * @since 2.0 - */ -public class JoiningStrategyJoinColumnsWithOverrideOptionComposite - extends Pane<ReadOnlyJoinColumnRelationshipStrategy> -{ - - private JoiningStrategyJoinColumnsComposite joiningStrategyComposite; - - public JoiningStrategyJoinColumnsWithOverrideOptionComposite( - Pane<?> parentPane, - PropertyValueModel<ReadOnlyJoinColumnRelationshipStrategy> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - // Override Default Join Columns check box - addCheckBox( - addSubPane(container, 8), - JptUiDetailsMessages.JoiningStrategyJoinColumnsComposite_overrideDefaultJoinColumns, - buildOverrideDefaultJoinColumnHolder(), - null - ); - - this.joiningStrategyComposite = new JoiningStrategyJoinColumnsComposite(this, getSubjectHolder(), container); - } - - void setSelectedJoinColumn(JoinColumn joinColumn) { - this.joiningStrategyComposite.setSelectedJoinColumn(joinColumn); - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - ListValueModel<ReadOnlyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<ReadOnlyJoinColumnRelationshipStrategy, ReadOnlyJoinColumn>( - getSubjectHolder(), ReadOnlyJoinColumnRelationshipStrategy.SPECIFIED_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<ReadOnlyJoinColumn> listIterator_() { - return new SuperListIteratorWrapper<ReadOnlyJoinColumn>(this.subject.specifiedJoinColumns()); - } - - @Override - protected int size_() { - return this.subject.specifiedJoinColumnsSize(); - } - }; - } - - private class OverrideDefaultJoinColumnHolder - extends ListPropertyValueModelAdapter<Boolean> - implements WritablePropertyValueModel<Boolean> - { - public OverrideDefaultJoinColumnHolder() { - super(buildSpecifiedJoinColumnsListHolder()); - } - - @Override - protected Boolean buildValue() { - return Boolean.valueOf(this.listHolder.size() > 0); - } - - public void setValue(Boolean value) { - updateJoinColumns(value.booleanValue()); - } - - private void updateJoinColumns(boolean selected) { - if (isPopulating()) { - return; - } - - setPopulating(true); - - try { - JoinColumnRelationshipStrategy subject = (JoinColumnRelationshipStrategy) getSubject(); - - // Add a join column by creating a specified one using the default - // one if it exists - if (selected) { - ReadOnlyJoinColumn defaultJoinColumn = subject.getDefaultJoinColumn();//TODO could be null, disable override default check box? - - if (defaultJoinColumn != null) { - String columnName = defaultJoinColumn.getDefaultName(); - String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName(); - - JoinColumn joinColumn = subject.addSpecifiedJoinColumn(); - joinColumn.setSpecifiedName(columnName); - joinColumn.setSpecifiedReferencedColumnName(referencedColumnName); - - JoiningStrategyJoinColumnsWithOverrideOptionComposite.this.setSelectedJoinColumn(joinColumn); - } - } - // Remove all the specified join columns - else { - for (int index = subject.specifiedJoinColumnsSize(); --index >= 0; ) { - subject.removeSpecifiedJoinColumn(index); - } - } - } - finally { - setPopulating(false); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java deleted file mode 100644 index 88415df3e4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali mapping panes. - * - * @version 2.3 - * @since 1.0 - */ -public class JptUiDetailsMessages { - - public static String AccessTypeCombo_default; - public static String AddQueryDialog_name; - public static String AddQueryDialog_queryType; - public static String AddQueryDialog_title; - public static String AddQueryDialog_descriptionTitle; - public static String AddQueryDialog_description; - public static String AddQueryDialog_nameExists; - public static String AddQueryDialog_namedQuery; - public static String AddQueryDialog_namedNativeQuery; - public static String QueryStateObject_nameMustBeSpecified; - public static String QueryStateObject_typeMustBeSpecified; - public static String NamedQueryComposite_nameTextLabel; - - public static String OverridesComposite_attributeOverridesGroup; - public static String OverridesComposite_attributeOverridesSection; - public static String OverridesComposite_overrideDefault; - - public static String BasicSection_title; - public static String EmbeddableSection_title; - public static String EmbeddedSection_title; - public static String EmbeddedIdSection_title; - public static String EntitySection_title; - public static String IdSection_title; - public static String ManyToManySection_title; - public static String ManyToOneSection_title; - public static String MappedSuperclassSection_title; - public static String OneToManySection_title; - public static String OneToOneSection_title; - public static String VersionSection_title; - - public static String BasicGeneralSection_enumeratedLabel; - public static String BasicGeneralSection_fetchLabel; - public static String BasicGeneralSection_lobLabel; - public static String BasicGeneralSection_name; - public static String BasicGeneralSection_nameDefault; - public static String BasicGeneralSection_optionalLabel; - public static String BasicGeneralSection_optionalLabelDefault; - public static String BasicGeneralSection_temporalLabel; - public static String TypeSection_type; - public static String TypeSection_default; - public static String TypeSection_lob; - public static String TypeSection_temporal; - public static String TypeSection_enumerated; - public static String CascadeComposite_all; - public static String CascadeComposite_cascadeTitle; - public static String CascadeComposite_merge; - public static String CascadeComposite_persist; - public static String CascadeComposite_refresh; - public static String CascadeComposite_remove; - public static String CatalogChooser_label; - public static String ColumnComposite_columnDefinition; - public static String ColumnComposite_columnSection; - public static String ColumnComposite_details; - public static String ColumnComposite_insertable; - public static String ColumnComposite_insertableWithDefault; - public static String ColumnComposite_length; - public static String ColumnComposite_name; - public static String ColumnComposite_nullable; - public static String ColumnComposite_nullableWithDefault; - public static String ColumnComposite_precision; - public static String ColumnComposite_scale; - public static String ColumnComposite_table; - public static String ColumnComposite_unique; - public static String ColumnComposite_uniqueWithDefault; - public static String ColumnComposite_updatable; - public static String ColumnComposite_updatableWithDefault; - public static String ProviderDefault; - public static String DiscriminatorColumnComposite_discriminatorType; - public static String DiscriminatorColumnComposite_name; - public static String DiscriminatorColumnComposite_char; - public static String DiscriminatorColumnComposite_integer; - public static String DiscriminatorColumnComposite_string; - public static String EntityComposite_inheritance; - public static String EntityComposite_queries; - public static String EntityComposite_tableDefault; - public static String EntityComposite_tableNoDefaultSpecified; - public static String EntityGeneralSection_name; - public static String EntityNameComposite_name; - public static String EnumTypeComposite_ordinal; - public static String EnumTypeComposite_string; - public static String FetchTypeComposite_eager; - public static String FetchTypeComposite_lazy; - public static String GeneratedValueComposite_auto; - public static String GeneratedValueComposite_generatedValue; - public static String GeneratedValueComposite_generatorName; - public static String GeneratedValueComposite_identity; - public static String GeneratedValueComposite_sequence; - public static String GeneratedValueComposite_strategy; - public static String GeneratedValueComposite_table; - public static String GeneratorComposite_allocationSize; - public static String GeneratorComposite_initialValue; - public static String GeneratorsComposite_sequenceGeneratorCheckBox; - public static String GeneratorsComposite_sequenceGeneratorSection; - public static String GeneratorsComposite_tableGeneratorCheckBox; - public static String GeneratorsComposite_tableGeneratorSection; - public static String IdClassComposite_label; - public static String IdMappingComposite_pk_generation; - public static String IdMappingComposite_primaryKeyGenerationCheckBox; - public static String IdMappingComposite_primaryKeyGenerationSection; - public static String IdMappingComposite_sequenceGeneratorCheckBox; - public static String IdMappingComposite_sequenceGeneratorSection; - public static String IdMappingComposite_tableGeneratorCheckBox; - public static String IdMappingComposite_tableGeneratorSection; - public static String InheritanceComposite_detailsGroupBox; - public static String InheritanceComposite_discriminatorColumnGroupBox; - public static String InheritanceComposite_discriminatorValue; - public static String AbstractInheritanceComposite_joined; - public static String AbstractInheritanceComposite_single_table; - public static String InheritanceComposite_strategy; - public static String AbstractInheritanceComposite_table_per_class; - public static String InverseJoinColumnDialog_editInverseJoinColumnTitle; - public static String Joining_title; - public static String Joining_mappedByLabel; - public static String Joining_mappedByAttributeLabel; - public static String Joining_joinColumnJoiningLabel; - public static String Joining_primaryKeyJoinColumnJoiningLabel; - public static String Joining_joinTableJoiningLabel; - public static String JoinColumnsComposite_edit; - public static String JoinColumnsComposite_mappingBetweenTwoParams; - public static String JoinColumnsComposite_mappingBetweenTwoParamsBothDefault; - public static String JoinColumnsComposite_mappingBetweenTwoParamsDefault; - public static String JoinColumnsComposite_mappingBetweenTwoParamsFirstDefault; - public static String JoinColumnsComposite_mappingBetweenTwoParamsSecDefault; - public static String JoiningStrategyJoinColumnsComposite_overrideDefaultJoinColumns; - public static String JoinColumnDialog_addJoinColumnDescriptionTitle; - public static String JoinColumnDialog_addJoinColumnTitle; - public static String JoinColumnDialog_description; - public static String JoinColumnDialog_editJoinColumnDescriptionTitle; - public static String JoinColumnDialog_editJoinColumnTitle; - public static String JoinColumnDialog_name; - public static String JoinColumnDialog_referencedColumnName; - public static String JoinColumnDialogPane_columnDefinition; - public static String JoinColumnDialogPane_insertable; - public static String JoinColumnDialogPane_insertableWithDefault; - public static String JoinColumnDialogPane_nullable; - public static String JoinColumnDialogPane_nullableWithDefault; - public static String JoinColumnDialogPane_table; - public static String JoinColumnDialogPane_unique; - public static String JoinColumnDialogPane_uniqueWithDefault; - public static String JoinColumnDialogPane_updatable; - public static String JoinColumnDialogPane_updatableWithDefault; - public static String JoinTableComposite_inverseJoinColumn; - public static String JoinTableComposite_joinColumn; - public static String JoinTableComposite_name; - public static String JoinTableComposite_schema; - public static String JoinTableComposite_catalog; - public static String JoinTableComposite_overrideDefaultInverseJoinColumns; - public static String JoinTableComposite_overrideDefaultJoinColumns; - - public static String DefaultBasicMappingUiProvider_label; - public static String DefaultEmbeddedMappingUiProvider_label; - public static String BasicMappingUiProvider_label; - public static String EmbeddedIdMappingUiProvider_label; - public static String EmbeddedMappingUiProvider_label; - public static String IdMappingUiProvider_label; - public static String ManyToManyMappingUiProvider_label; - public static String ManyToOneMappingUiProvider_label; - public static String OneToManyMappingUiProvider_label; - public static String OneToOneMappingUiProvider_label; - public static String TransientMappingUiProvider_label; - public static String VersionMappingUiProvider_label; - public static String DefaultBasicMappingUiProvider_linkLabel; - public static String DefaultEmbeddedMappingUiProvider_linkLabel; - public static String BasicMappingUiProvider_linkLabel; - public static String EmbeddedIdMappingUiProvider_linkLabel; - public static String EmbeddedMappingUiProvider_linkLabel; - public static String IdMappingUiProvider_linkLabel; - public static String ManyToManyMappingUiProvider_linkLabel; - public static String ManyToOneMappingUiProvider_linkLabel; - public static String OneToManyMappingUiProvider_linkLabel; - public static String OneToOneMappingUiProvider_linkLabel; - public static String TransientMappingUiProvider_linkLabel; - public static String VersionMappingUiProvider_linkLabel; - - public static String MapAsComposite_changeMappingType; - public static String MapAsComposite_default; - public static String MapAsComposite_dialogTitle; - public static String MapAsComposite_labelText; - public static String MapAsComposite_mappedAttributeText; - public static String MapAsComposite_mappedTypeText; - public static String MapAsComposite_unmappedAttributeText; - public static String MapAsComposite_unmappedTypeText; - public static String MapAsComposite_virtualAttributeText; - - public static String EmbeddableUiProvider_label; - public static String EntityUiProvider_label; - public static String MappedSuperclassUiProvider_label; - public static String EmbeddableUiProvider_linkLabel; - public static String EntityUiProvider_linkLabel; - public static String MappedSuperclassUiProvider_linkLabel; - - public static String NullTypeMappingUiProvider_label; - - public static String MetaDataCompleteCombo_Default; - public static String MultiRelationshipMappingComposite_cascadeType; - public static String MultiRelationshipMappingComposite_fetchType; - public static String MultiRelationshipMappingComposite_general; - public static String MultiRelationshipMappingComposite_joinTable; - public static String MultiRelationshipMappingComposite_mappedBy; - public static String MultiRelationshipMappingComposite_targetEntity; - public static String NamedNativeQueryPropertyComposite_query; - public static String NamedNativeQueryPropertyComposite_queryHintsGroupBox; - public static String NamedNativeQueryPropertyComposite_resultClass; - public static String NamedQueryPropertyComposite_query; - public static String NamedQueryPropertyComposite_queryHintsGroupBox; - public static String NoNameSet; - public static String NullAttributeMappingUiProvider_label; - public static String OptionalComposite_false; - public static String OptionalComposite_true; - public static String OrderingComposite_custom; - public static String OrderingComposite_none; - public static String OrderingComposite_orderingGroup; - public static String OrderingComposite_primaryKey; - public static String OrmSecondaryTablesComposite_defineInXml; - public static String OverridesComposite_association; - public static String OverridesComposite_attribute; - public static String AssociationOverridesComposite_joinColumn; - public static String OverridesComposite_noName; - public static String PrimaryKeyJoinColumnDialog_addDescriptionTitle; - public static String PrimaryKeyJoinColumnDialog_addTitle; - public static String PrimaryKeyJoinColumnDialog_editDescriptionTitle; - public static String PrimaryKeyJoinColumnDialog_editTitle; - public static String PrimaryKeyJoinColumnInSecondaryTableDialog_addDescriptionTitle; - public static String PrimaryKeyJoinColumnInSecondaryTableDialog_addTitle; - public static String PrimaryKeyJoinColumnInSecondaryTableDialog_editDescriptionTitle; - public static String PrimaryKeyJoinColumnInSecondaryTableDialog_editTitle; - public static String PrimaryKeyJoinColumnsComposite_edit; - public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParams; - public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsBothDefault; - public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsDefault; - public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsFirstDefault; - public static String PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsSecDefault; - public static String PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns; - public static String PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn; - public static String QueriesComposite_displayString; - public static String QueryHintsComposite_nameColumn; - public static String QueryHintsComposite_valueColumn; - public static String SchemaChooser_label; - public static String SecondaryTableDialog_addSecondaryTable; - public static String SecondaryTableDialog_catalog; - public static String SecondaryTableDialog_defaultCatalog; - public static String SecondaryTableDialog_defaultSchema; - public static String SecondaryTableDialog_editSecondaryTable; - public static String SecondaryTableDialog_name; - public static String SecondaryTableDialog_schema; - public static String SecondaryTablesComposite_edit; - public static String SecondaryTablesComposite_secondaryTables; - public static String SequenceGeneratorComposite_catalog; - public static String SequenceGeneratorComposite_default; - public static String SequenceGeneratorComposite_name; - public static String SequenceGeneratorComposite_schema; - public static String SequenceGeneratorComposite_sequence; - public static String SequenceGeneratorComposite_sequenceGenerator; - public static String TableChooser_label; - public static String TableComposite_tableSection; - public static String TableGeneratorComposite_catalog; - public static String TableGeneratorComposite_default; - public static String TableGeneratorComposite_name; - public static String TableGeneratorComposite_pkColumn; - public static String TableGeneratorComposite_pkColumnValue; - public static String TableGeneratorComposite_schema; - public static String TableGeneratorComposite_table; - public static String TableGeneratorComposite_tableGenerator; - public static String TableGeneratorComposite_valueColumn; - public static String TargetEntityChooser_browse; - public static String TargetEntityChooser_label; - public static String TargetEntityChooser_selectTypeTitle; - public static String TemporalTypeComposite_date; - public static String TemporalTypeComposite_time; - public static String TemporalTypeComposite_timestamp; - - private static final String BUNDLE_NAME = "jpt_ui_details"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiDetailsMessages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiDetailsMessages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToManyJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToManyJoiningStrategyPane.java deleted file mode 100644 index 5685bd06af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToManyJoiningStrategyPane.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinTableRelationship; -import org.eclipse.jpt.jpa.core.context.ManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.ManyToManyRelationship; -import org.eclipse.jpt.jpa.core.context.MappedByRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableStrategyPane _____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToManyMapping} - * @see {@link ManyToManyRelationship} - * @see {@link ManyToManyMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinTableStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class ManyToManyJoiningStrategyPane - extends Pane<ManyToManyRelationship> -{ - public ManyToManyJoiningStrategyPane( - Pane<?> parentPane, - PropertyValueModel<? extends ManyToManyRelationship> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_mappedByLabel, - MappedByJoiningStrategyPane.buildUsesMappedByJoiningStrategyHolder(getSubjectHolder()), - null); - - new MappedByJoiningStrategyPane(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinTableJoiningLabel, - JoinTableJoiningStrategyPane.buildUsesJoinTableJoiningStrategyHolder(getSubjectHolder()), - null); - - new JoinTableJoiningStrategyPane(this, composite); - - addSubPane(composite, 5); - } - - protected WritablePropertyValueModel<Boolean> buildUsesMappedByStrategyHolder() { - return new PropertyAspectAdapter<MappedByRelationship, Boolean>( - this.getSubjectHolder(), ReadOnlyRelationship.STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.strategyIsMappedBy()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setStrategyToMappedBy(); - } - //value == FALSE - selection of another radio button causes this strategy to get unset - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildUsesJoinTableStrategyHolder() { - return new PropertyAspectAdapter<JoinTableRelationship, Boolean>( - this.getSubjectHolder(), ReadOnlyRelationship.STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.strategyIsJoinTable()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setStrategyToJoinTable(); - } - //value == FALSE - selection of another radio button causes this strategy to get unset - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToManyMappingComposite.java deleted file mode 100644 index a2ffd3aa2f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToManyMappingComposite.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.ManyToManyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrderingComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToManyMapping} - * @see {@link TargetEntityComposite} - * @see {@link ManyToManyJoiningStrategyPane} - * @see {@link FetchTypeComposite} - * @see {@link CascadeComposite} - * @see {@link OrderingComposite} - * - * @version 2.3 - * @since 1.0 - */ -public class ManyToManyMappingComposite - extends AbstractManyToManyMappingComposite<ManyToManyMapping, ManyToManyRelationship> -{ - /** - * Creates a new <code>ManyToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IManyToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public ManyToManyMappingComposite(PropertyValueModel<? extends ManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeManyToManySection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToOneJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToOneJoiningStrategyPane.java deleted file mode 100644 index dfc728863f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToOneJoiningStrategyPane.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToOneRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o JoinColumnStrategyPane ____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToOneMapping} - * @see {@link ManyToOneRelationship} - * @see {@link ManyToOneMappingComposite} - * @see {@link JoinColumnStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class ManyToOneJoiningStrategyPane extends Pane<ManyToOneRelationship> -{ - public ManyToOneJoiningStrategyPane( - Pane<?> parentPane, - PropertyValueModel<? extends ManyToOneRelationship> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinColumnJoiningLabel, - JoinColumnJoiningStrategyPane.buildUsesJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox(this, composite); - - addSubPane(composite, 5); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToOneMappingComposite.java deleted file mode 100644 index 903149fe3d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ManyToOneMappingComposite.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.ManyToOneRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToOneMapping} - * @see {@link TargetEntityComposite} - * @see {@link ManyToOneJoiningStrategyPane} - * @see {@link FetchTypeComposite} - * @see {@link OptionalComposite} - * @see {@link CascadeComposite} - * - * @version 2.3 - * @since 1.0 - */ -public class ManyToOneMappingComposite - extends AbstractManyToOneMappingComposite<ManyToOneMapping, ManyToOneRelationship> -{ - /** - * Creates a new <code>ManyToOneMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IManyToOneMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public ManyToOneMappingComposite(PropertyValueModel<? extends ManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeManyToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MapAsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MapAsComposite.java deleted file mode 100644 index fc573e777a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MapAsComposite.java +++ /dev/null @@ -1,638 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.Comparator; -import java.util.Iterator; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.JFaceColors; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseMoveListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; -import com.ibm.icu.text.Collator; - -/** - * This map as composite simply shows a styled text where the name of the - * mapping and its type are displayed. The mapping type can be clicked on to - * invoke a dialog in order to change the type. - * <p> - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | Attribute 'name' is mapped as one to one. | - * | ¯¯¯¯¯¯¯¯¯¯ | - * -----------------------------------------------------------------------------</pre> - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public abstract class MapAsComposite<T extends JpaNode> extends Pane<T> { - - protected boolean dragEvent; - protected boolean enabled; - protected Cursor handCursor; - protected MappingChangeHandler<T> mappingChangeHandler; - protected int mappingTypeLength; - protected int mappingTypeStart; - protected boolean mouseDown; - protected int nameLength; - protected int nameStart; - protected StyledText styledText; - - /** - * The constant ID used to retrieve the dialog settings. - */ - private static final String DIALOG_SETTINGS = "org.eclipse.jpt.jpa.ui.dialogs.MapAsDialog"; - - /** - * Creates a new <code>MapAsComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public MapAsComposite(Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Returns the JPT platform responsble to manage the user interface part of - * the JPT plug-in. - * - * @return The UI platform of the JPT plug-in - */ - protected JpaPlatformUi getJpaPlatformUi() { - String platformId = getSubject().getJpaProject().getJpaPlatform().getId(); - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(platformId); - } - - /** - * Creates the default provider responsible for clearing the mapping type. - * Return null if there is not a default provider - * @return A provider that acts as a default mapping provider - */ - protected abstract DefaultMappingUiDefinition getDefaultDefinition(); - - protected abstract DefaultMappingUiDefinition getDefaultDefinition(String mappingKey); - - protected MappingUiDefinition getMappingUiDefinition(String mappingKey) { - for (MappingUiDefinition<T, ?> provider : CollectionTools.iterable(this.mappingChangeHandler.mappingUiDefinitions())) { - if (provider.getKey() == mappingKey) { - return provider; - } - } - return null; - } - - /** - * Creates the handler responsible to give the information required for - * completing the behavior of this pane. - * - * @return A new <code>MappingChangeHandler</code> - */ - protected abstract MappingChangeHandler buildMappingChangeHandler(); - - private MouseListener buildMouseListener() { - return new MouseListener() { - public void mouseDoubleClick(MouseEvent e) { - } - - public void mouseDown(MouseEvent e) { - if (e.button == 1) { - mouseDown = true; - } - } - - public void mouseUp(MouseEvent e) { - mouseDown = false; - StyledText text = (StyledText) e.widget; - int offset = text.getCaretOffset(); - - if (dragEvent) { - dragEvent = false; - - if (isOverLink(offset)) { - text.setCursor(handCursor); - } - } - else if (isOverLink(offset)) { - text.setCursor(handCursor); - openMappingSelectionDialog(); - text.setCursor(null); - } - } - }; - } - - private MouseMoveListener buildMouseMoveListener() { - return new MouseMoveListener() { - public void mouseMove(MouseEvent e) { - StyledText text = (StyledText) e.widget; - - if (mouseDown) { - if (!dragEvent) { - text.setCursor(null); - } - - dragEvent = true; - return; - } - - int offset = -1; - - try { - offset = text.getOffsetAtLocation(new Point(e.x, e.y)); - } - catch (IllegalArgumentException ex) { - } - - if (isOverLink(offset)) { - text.setCursor(handCursor); - } - else { - text.setCursor(null); - } - } - }; - } - - private PostExecution<MappingSelectionDialog> buildPostExecution() { - - return new PostExecution<MappingSelectionDialog>() { - public void execute(MappingSelectionDialog dialog) { - - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - MappingUiDefinition definition = (MappingUiDefinition) dialog.getFirstResult(); - morphMapping(definition); - } - } - }; - } - - /** - * Creates the full localized string by formatting the label text returned - * by the <code>MappingChangeHandler</code> with the mapping name and the - * mapping type. - * - * @param name The display string of the mapping being edited - * @param mappingType The localized message describing the mapping type - * @return The localized string describing the mapping - */ - protected String buildText(String name, String mappingType) { - return NLS.bind( - mappingChangeHandler.getLabelText(), - name, - mappingType - ); - } - - /** - * Removes any style applied to the styled text. - */ - protected void clearStyleRange() { - styledText.setStyleRange(null); - } - - /* - * (non-Javadoc) - */ - @Override - protected void doPopulate() { - super.doPopulate(); - updateDescription(); - } - - /* - * (non-Javadoc) - */ - @Override - public void enableWidgets(boolean enabled) { - this.enabled = enabled; - super.enableWidgets(enabled); - - if (!styledText.isDisposed()) { - styledText.setEnabled(enabled); - - if (enabled) { - updateLinkRange(); - } - else { - clearStyleRange(); - } - } - } - - /* - * (non-Javadoc) - */ - @Override - protected void initialize() { - - super.initialize(); - - this.enabled = true; - this.mappingChangeHandler = buildMappingChangeHandler(); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - handCursor = getShell().getDisplay().getSystemCursor(SWT.CURSOR_HAND); - - styledText = new StyledText(container, SWT.WRAP | SWT.READ_ONLY); - styledText.addMouseListener(buildMouseListener()); - styledText.addMouseMoveListener(buildMouseMoveListener()); - styledText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - /** - * Retreive the <code>MappingUiDefinition</code> that provides the UI for the - * current mapping. - * - * @return The <code>MappingUiProvider</code> representing the type of the - * mapping being edited - */ - protected MappingUiDefinition initialSelection() { - - for (Iterator<? extends MappingUiDefinition> iter = this.mappingChangeHandler.mappingUiDefinitions(); iter.hasNext(); ) { - MappingUiDefinition definition = iter.next(); - - if (getMappingKey() == definition.getKey()) { - return definition; - } - } - - return null; - } - - /** - * Determines whether the given location is within the mapping type range. - * - * @param location The mouse location in character coordinate - * @return <code>true</code> if the mouse is over the mapping type text; - * <code>false</code> otherwise - */ - protected boolean isOverLink(int location) { - - return (location >= mappingTypeStart && - location <= mappingTypeStart + mappingTypeLength); - } - - /** - * Returns the mapping key representing the current mapping object. - * - * @return A non-<code>null</code> unique identifier representing the type - * of the mapping being edited - */ - protected abstract String getMappingKey(); - - /** - * Aks the <code>MappingChangeHandler</code> to change the mapping type using - * the given <code>MappingUiDefinition</code>. - * - * @param provider The provider used to determine the mapping type used for - * morphing the mapping being edited - */ - protected void morphMapping(MappingUiDefinition definition) { - mappingChangeHandler.morphMapping(definition); - } - - /** - * Opens the dialog that shows the registered mapping types in order for the - * user to select a provider in order to change the mapping type of the - * mapping being edited. - */ - protected void openMappingSelectionDialog() { - - MappingSelectionDialog dialog = new MappingSelectionDialog(); - SWTUtil.show(dialog, buildPostExecution()); - } - - /** - * Updates the description by recreating the label. - */ - protected void updateDescription() { - if (getSubject() == null) { - return; - } - - clearStyleRange(); - updateText(); - - if (enabled) { - updateLinkRange(); - } - } - - /** - * Updates the colors of the text: (1) the name is shown in bold and (2) the - * mapping type is shown in bold and in hyperlink color. - */ - protected void updateLinkRange() { - - Color linkColor = JFaceColors.getHyperlinkText(getShell().getDisplay()); - - // Make the name bold - StyleRange styleRange = new StyleRange( - nameStart, nameLength, - null, null, - SWT.BOLD - ); - styledText.setStyleRange(styleRange); - - // Make the mapping type shown as a hyperlink - if (mappingTypeStart > -1) { - styleRange = new StyleRange( - mappingTypeStart, mappingTypeLength, - linkColor, null - ); - - styleRange.underline = true; - styleRange.underlineColor = linkColor; - styleRange.underlineStyle = SWT.UNDERLINE_SINGLE; - styledText.setStyleRange(styleRange); - } - } - - /** - * Updates the styles text's input. - */ - protected void updateText() { - - String name = mappingChangeHandler.getName(); - - if (name == null) { - name = JptUiDetailsMessages.NoNameSet; - } - - String mappingType = mappingChangeHandler.getMappingText(); - String text = buildText(name, mappingType); - - mappingTypeStart = text.lastIndexOf(mappingType); - mappingTypeLength = mappingType.length(); - - nameStart = text.indexOf(name); - nameLength = name.length(); - - styledText.setText(text); - } - - @Override - public void dispose() { - this.styledText.dispose(); - super.dispose(); - } - - /** - * This handler is responsible to give the text information and to open the - * mapping dialog if the user clicked on the mapping type. - */ - protected interface MappingChangeHandler<T> { - - /** - * Returns the entire text describing the mapping (entity or mapping) and - * its type. - * - * @return A localized text with two arguments where the first one should - * be replaced by the name and the second be replaced by the mapping type - */ - String getLabelText(); - - /** - * Returns the displayable text representing the mapping type. - * - * @return A human readable text describing the mapping type - */ - String getMappingText(); - - /** - * Morphes the current mapping into a new type by using the given provider. - * - * @param provider The definition that was selected for changing the mapping - */ - void morphMapping(MappingUiDefinition<T, ?> definition); - - /** - * Returns the name of the current mapping. - * - * @return The displayable name of the mapping - */ - String getName(); - - /** - * Returns the list of mapping UI definitions that are registered with the JPT plugin. - * - * @return The supported types of mapping - */ - Iterator<MappingUiDefinition<T, ?>> mappingUiDefinitions(); - } - - /** - * This dialog shows the list of possible mapping types and lets the user - * the option to filter them using a search field. - */ - protected class MappingSelectionDialog extends FilteredItemsSelectionDialog - { - private MappingUiDefinition defaultDefinition; - - /** - * Creates a new <code>MappingSelectionDialog</code>. - */ - private MappingSelectionDialog() { - super(MapAsComposite.this.getShell(), false); - setMessage(JptUiDetailsMessages.MapAsComposite_labelText); - setTitle(JptUiDetailsMessages.MapAsComposite_dialogTitle); - setListLabelProvider(buildLabelProvider()); - setDetailsLabelProvider(buildLabelProvider()); - } - - private ILabelProvider buildLabelProvider() { - return new LabelProvider() { - - @Override - public Image getImage(Object element) { - - if (element == null) { - return null; - } - - MappingUiDefinition definition = (MappingUiDefinition) element; - return definition.getImage(); - } - - @Override - public String getText(Object element) { - if (element == null) { - return ""; - } - - MappingUiDefinition definition = (MappingUiDefinition) element; - return definition.getLabel(); - } - }; - } - - @Override - protected Control createExtendedContentArea(Composite parent) { - return null; - } - - @Override - protected ItemsFilter createFilter() { - return new MappingTypeItemsFilter(); - } - - @Override - protected void fillContentProvider( - AbstractContentProvider provider, - ItemsFilter itemsFilter, - IProgressMonitor monitor) throws CoreException { - - monitor.beginTask(null, -1); - - try { - // Add the default provider - defaultDefinition = getDefaultDefinition(); - - if (defaultDefinition != null) { - provider.add(defaultDefinition, itemsFilter); - } - - // Add the registered mapping providers to the dialog - for (Iterator<MappingUiDefinition<T, ?>> iter = mappingChangeHandler.mappingUiDefinitions(); iter.hasNext(); ) { - MappingUiDefinition mappingDefinition = iter.next(); - if (mappingDefinition.isEnabledFor(getSubject())) { - provider.add(mappingDefinition, itemsFilter); - } - } - } - finally { - monitor.done(); - } - } - - @Override - protected IDialogSettings getDialogSettings() { - - IDialogSettings dialogSettings = JptJpaUiPlugin.instance().getDialogSettings(); - IDialogSettings settings = dialogSettings.getSection(DIALOG_SETTINGS); - - if (settings == null) { - settings = dialogSettings.addNewSection(DIALOG_SETTINGS); - } - - return settings; - } - - @Override - public String getElementName(Object object) { - MappingUiDefinition definition = (MappingUiDefinition) object; - return definition.getLabel(); - } - - @Override - protected Comparator<MappingUiDefinition> getItemsComparator() { - return new Comparator<MappingUiDefinition>() { - public int compare(MappingUiDefinition item1, MappingUiDefinition item2) { - - if (item1 == defaultDefinition) { - return -1; - } - - if (item2 == defaultDefinition) { - return 1; - } - - String displayString1 = item1.getLabel(); - String displayString2 = item2.getLabel(); - return Collator.getInstance().compare(displayString1, displayString2); - } - }; - } - - @Override - protected IStatus validateItem(Object item) { - - if (item == null) { - return new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, IStatus.ERROR, "", null); - } - - return Status.OK_STATUS; - } - - /** - * Create the filter responsible to remove any mapping type based on the - * pattern entered in the text field. - */ - private class MappingTypeItemsFilter extends ItemsFilter { - - /** - * Creates a new <code>MappingTypeItemsFilter</code>. - */ - MappingTypeItemsFilter() { - - super(); - - // Make sure that if the pattern is empty, we specify * in order - // to show all the mapping types - if (StringTools.stringIsEmpty(getPattern())) { - patternMatcher.setPattern("*"); - } - } - - @Override - public boolean isConsistentItem(Object item) { - return true; - } - - @Override - public boolean matchItem(Object item) { - MappingUiDefinition definition = (MappingUiDefinition) item; - return matches(definition.getLabel()); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MappedByJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MappedByJoiningStrategyPane.java deleted file mode 100644 index 5143c9f5bc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MappedByJoiningStrategyPane.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.MappedByRelationship; -import org.eclipse.jpt.jpa.core.context.MappedByRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Mapped by _____________________________________________________________ | - * | | --------------------------------------------- ---------- | | - * | | Attribute: | | |Browse..| | | - * | | --------------------------------------------- ---------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link MappedByRelationship} - * @see {@link MappedByRelationshipStrategy} - * @see {@link OneToOneJoiningStrategyPane} - * @see {@link OneToManyJoiningStrategyPane} - * @see {@link ManyToManyJoiningStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class MappedByJoiningStrategyPane - extends AbstractJoiningStrategyPane<MappedByRelationship, MappedByRelationshipStrategy> -{ - /** - * Creates a new <code>MappedByJoiningStrategyPane</code>. - * - * @param parentPane The parent form pane - * @param parent The parent container - */ - public MappedByJoiningStrategyPane( - Pane<? extends MappedByRelationship> parentPane, - Composite parent) { - super(parentPane, parent); - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - return new MappedByPane(this, this.buildMappedByJoiningStrategyHolder(), parent).getControl(); - } - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return buildUsesMappedByJoiningStrategyHolder(getSubjectHolder()); - } - - protected PropertyValueModel<MappedByRelationshipStrategy> buildMappedByJoiningStrategyHolder() { - return new PropertyAspectAdapter<MappedByRelationship, MappedByRelationshipStrategy>( - getSubjectHolder()) { - @Override - protected MappedByRelationshipStrategy buildValue_() { - return this.subject.getMappedByStrategy(); - } - }; - } - - public static WritablePropertyValueModel<Boolean> buildUsesMappedByJoiningStrategyHolder(PropertyValueModel<? extends MappedByRelationship> subjectHolder) { - return new PropertyAspectAdapter<MappedByRelationship, Boolean>( - subjectHolder, ReadOnlyRelationship.STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.strategyIsMappedBy()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setStrategyToMappedBy(); - } - //value == FALSE - selection of another radio button causes this strategy to get unset - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MappedByPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MappedByPane.java deleted file mode 100644 index cac8094c2a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/MappedByPane.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.Iterator; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.MappedByRelationshipStrategy; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.widgets.Composite; - -import com.ibm.icu.text.Collator; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | -------------------------------------------------------------- | - * | Mapped By: | |v| | - * | -------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see NonOwningMapping - * @see ManyToManyMappingComposite - A container of this pane - * @see OneToManyMappingComposite - A container of this pane - * @see OneToOneMappingComposite - A container of this pane - * - * @version 2.0 - * @since 1.0 - */ -public class MappedByPane - extends Pane<MappedByRelationshipStrategy> -{ - /** - * Creates a new <code>MappedByPane</code>. - * - * @param parentPane The parent form pane - * @param subjectHolder The PVM for the {@link MappedByRelationshipStrategy} - * @param parent The parent container - */ - public MappedByPane( - Pane<?> parentPane, - PropertyValueModel<MappedByRelationshipStrategy> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - addLabeledEditableCombo( - container, - JptUiDetailsMessages.Joining_mappedByAttributeLabel, - buildCandidateAttributesListValueModel(), - buildAttributePropertyValueModel(), - JpaHelpContextIds.MAPPING_MAPPED_BY); - } - - @SuppressWarnings("unchecked") - protected ListValueModel<String> buildCandidateAttributesListValueModel() { - return new SortedListValueModelAdapter<String>( - new CollectionAspectAdapter<MappedByRelationshipStrategy, String>( - getSubjectHolder()) { - @Override - protected Iterator<String> iterator_() { - return this.subject.candidateMappedByAttributeNames(); - } - }, - Collator.getInstance() - ); - } - - protected WritablePropertyValueModel<String> buildAttributePropertyValueModel() { - return new PropertyAspectAdapter<MappedByRelationshipStrategy, String>( - getSubjectHolder(), MappedByRelationshipStrategy.MAPPED_BY_ATTRIBUTE_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getMappedByAttribute(); - } - - @Override - protected void setValue_(String value) { - this.subject.setMappedByAttribute(value); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedNativeQueryPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedNativeQueryPropertyComposite.java deleted file mode 100644 index 4d9515992a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedNativeQueryPropertyComposite.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.NamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | --------------------------------------------- ------------- | - * | Result Class: | I | | Browse... | | - * | --------------------------------------------- ------------- | - * | --------------------------------------------- | - * | Query: | I | | - * | | | | - * | | | | - * | | | | - * | --------------------------------------------- | - * | | - * | - Query Hints ----------------------------------------------------------- | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | QueryHintsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see NamedNativeQuery - * @see NamedNativeQueriesComposite - The parent container - * @see ClassChooserPane - * - * @version 2.0 - * @since 2.0 - */ -public class NamedNativeQueryPropertyComposite extends Pane<NamedNativeQuery> -{ - private ClassChooserPane<NamedNativeQuery> resultClassChooserPane; - - /** - * Creates a new <code>NamedNativeQueryPropertyComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public NamedNativeQueryPropertyComposite(Pane<?> parentPane, - PropertyValueModel<? extends NamedNativeQuery> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - private ClassChooserPane<NamedNativeQuery> addClassChooser(Composite container) { - - return new ClassChooserPane<NamedNativeQuery>(this, container) { - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<NamedNativeQuery, String>(getSubjectHolder(), NamedNativeQuery.RESULT_CLASS_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getResultClass(); - } - - @Override - protected void setValue_(String value) { - this.subject.setResultClass(value); - } - }; - } - - @Override - protected String getClassName() { - return getSubject().getResultClass(); - } - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.NamedNativeQueryPropertyComposite_resultClass; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected void setClassName(String className) { - getSubject().setResultClass(className); - } - - @Override - protected char getEnclosingTypeSeparator() { - return getSubject().getResultClassEnclosingTypeSeparator(); - } - }; - } - - private WritablePropertyValueModel<String> buildQueryHolder() { - return new PropertyAspectAdapter<NamedNativeQuery, String>(getSubjectHolder(), Query.QUERY_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getQuery(); - } - - @Override - protected void setValue_(String value) { - this.subject.setQuery(value); - } - }; - } - - @Override - public void enableWidgets(boolean enabled) { - super.enableWidgets(enabled); - this.resultClassChooserPane.enableWidgets(enabled); - } - - @Override - protected void initializeLayout(Composite container) { - - addLabeledText( - container, - JptUiDetailsMessages.NamedQueryComposite_nameTextLabel, - buildNameTextHolder()); - - // Result class chooser - this.resultClassChooserPane = addClassChooser(container); - - // Query text area - addLabeledMultiLineText( - container, - JptUiDetailsMessages.NamedNativeQueryPropertyComposite_query, - buildQueryHolder(), - 4, - null - ); - - // Query Hints pane - container = addTitledGroup( - addSubPane(container, 5), - JptUiDetailsMessages.NamedNativeQueryPropertyComposite_queryHintsGroupBox - ); - - new QueryHintsComposite(this, container); - } - - protected WritablePropertyValueModel<String> buildNameTextHolder() { - return new PropertyAspectAdapter<NamedNativeQuery, String>( - getSubjectHolder(), Query.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getName(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setName(value); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java deleted file mode 100644 index 8c1fbb12be..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------ | - * | Query: | I | | - * | | | | - * | | | | - * | ------------------------------------------------------------------ | - * | | - * | - Query Hints ----------------------------------------------------------- | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | QueryHintsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see NamedQuery - * @see NamedQueriesComposite - The parent container - * @see QueryHintsComposite - * - * @version 2.0 - * @since 2.0 - */ -public class NamedQueryPropertyComposite<T extends NamedQuery> extends Pane<T> -{ - /** - * Creates a new <code>NamedQueryPropertyComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public NamedQueryPropertyComposite(Pane<?> parentPane, - PropertyValueModel<T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - protected WritablePropertyValueModel<String> buildQueryHolder() { - return new PropertyAspectAdapter<NamedQuery, String>(getSubjectHolder(), Query.QUERY_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getQuery(); - } - - @Override - protected void setValue_(String value) { - this.subject.setQuery(value); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - addLabeledText( - container, - JptUiDetailsMessages.NamedQueryComposite_nameTextLabel, - buildNameTextHolder()); - - // Query text area - addLabeledMultiLineText( - container, - JptUiDetailsMessages.NamedQueryPropertyComposite_query, - buildQueryHolder(), - 4, - null - ); - - // Query Hints pane - container = addTitledGroup( - addSubPane(container, 5), - JptUiDetailsMessages.NamedQueryPropertyComposite_queryHintsGroupBox - ); - - new QueryHintsComposite(this, container); - } - - protected WritablePropertyValueModel<String> buildNameTextHolder() { - return new PropertyAspectAdapter<NamedQuery, String>( - getSubjectHolder(), Query.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getName(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setName(value); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToManyJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToManyJoiningStrategyPane.java deleted file mode 100644 index c5b3641989..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToManyJoiningStrategyPane.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToManyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableStrategyPane _____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OneToManyMapping} - * @see {@link OneToManyRelationship} - * @see {@link OneToManyMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinTableStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class OneToManyJoiningStrategyPane - extends Pane<OneToManyRelationship> -{ - public OneToManyJoiningStrategyPane( - Pane<?> parentPane, - PropertyValueModel<? extends OneToManyRelationship> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_mappedByLabel, - MappedByJoiningStrategyPane.buildUsesMappedByJoiningStrategyHolder(getSubjectHolder()), - null); - - new MappedByJoiningStrategyPane(this, composite); - - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinTableJoiningLabel, - JoinTableJoiningStrategyPane.buildUsesJoinTableJoiningStrategyHolder(getSubjectHolder()), - null); - - new JoinTableJoiningStrategyPane(this, composite); - - addSubPane(composite, 5); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToManyMappingComposite.java deleted file mode 100644 index de42ebc0b2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToManyMappingComposite.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToManyMapping; -import org.eclipse.jpt.jpa.core.context.OneToManyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrderingComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OneToManyMapping - * @see CascadeComposite - * @see FetchTypeComposite - * @see JoinTableComposite - * @see OrderingComposite - * @see TargetEntityComposite - * - * @version 2.3 - * @since 1.0 - */ -public class OneToManyMappingComposite - extends AbstractOneToManyMappingComposite<OneToManyMapping, OneToManyRelationship> -{ - /** - * Creates a new <code>OneToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IOneToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OneToManyMappingComposite(PropertyValueModel<? extends OneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeOneToManySection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToOneJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToOneJoiningStrategyPane.java deleted file mode 100644 index f18f0971cb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToOneJoiningStrategyPane.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToOneRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinColumnStrategyPane ____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o PrimaryKeyJoinColumnStrategyPane __________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OneToOneMapping} - * @see {@link OneToOneRelationship} - * @see {@link OneToOneMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinColumnStrategyPane} - * @see {@link PrimaryKeyJoinColumnStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class OneToOneJoiningStrategyPane - extends Pane<OneToOneRelationship> -{ - public OneToOneJoiningStrategyPane( - Pane<?> parentPane, - PropertyValueModel<? extends OneToOneRelationship> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_mappedByLabel, - MappedByJoiningStrategyPane.buildUsesMappedByJoiningStrategyHolder(getSubjectHolder()), - null); - - new MappedByJoiningStrategyPane(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_primaryKeyJoinColumnJoiningLabel, - PrimaryKeyJoinColumnJoiningStrategyPane.buildUsesPrimaryKeyJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - new PrimaryKeyJoinColumnJoiningStrategyPane(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinColumnJoiningLabel, - JoinColumnJoiningStrategyPane.buildUsesJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox(this, composite); - - addSubPane(composite, 5); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToOneMappingComposite.java deleted file mode 100644 index 128da9596e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OneToOneMappingComposite.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.core.context.OneToOneRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OneToOneMapping - * @see TargetEntityComposite - * @see JoiningStrategyComposite - * @see FetchTypeComposite - * @see OptionalComposite - * @see CascadeComposite - * - * @version 2.3 - * @since 1.0 - */ -public class OneToOneMappingComposite - extends AbstractOneToOneMappingComposite<OneToOneMapping, OneToOneRelationship> -{ - /** - * Creates a new <code>OneToOneMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IOneToOneMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OneToOneMappingComposite(PropertyValueModel<? extends OneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeOneToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OptionalComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OptionalComposite.java deleted file mode 100644 index 1ed91c256b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OptionalComposite.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OptionalMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * This composite simply shows a tri-state check box for the Optional option. - * - * @see BasicMapping - * @see BasicMappingComposite - A container of this pane - * @see ManyToOneMappingComposite - A container of this pane - * @see OneToOneMappingComposite - A container of this pane - * - * @version 1.0 - * @since 2.0 - */ -public class OptionalComposite extends Pane<OptionalMapping> -{ - /** - * Creates a new <code>OptionalComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OptionalComposite(Pane<? extends OptionalMapping> parentPane, - Composite parent) - { - super(parentPane, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - addTriStateCheckBoxWithDefault( - addSubPane(container, 4), - JptUiDetailsMessages.BasicGeneralSection_optionalLabel, - buildOptionalHolder(), - buildOptionalStringHolder(), - JpaHelpContextIds.MAPPING_OPTIONAL - ); - } - private WritablePropertyValueModel<Boolean> buildOptionalHolder() { - return new PropertyAspectAdapter<OptionalMapping, Boolean>(getSubjectHolder(), OptionalMapping.SPECIFIED_OPTIONAL_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedOptional(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedOptional(value); - } - }; - } - - private PropertyValueModel<String> buildOptionalStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultOptionalHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.BasicGeneralSection_optionalLabelDefault, defaultStringValue); - } - return JptUiDetailsMessages.BasicGeneralSection_optionalLabel; - } - }; - } - - - private PropertyValueModel<Boolean> buildDefaultOptionalHolder() { - return new PropertyAspectAdapter<OptionalMapping, Boolean>( - getSubjectHolder(), - OptionalMapping.SPECIFIED_OPTIONAL_PROPERTY, - OptionalMapping.DEFAULT_OPTIONAL_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedOptional() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultOptional()); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OrderingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OrderingComposite.java deleted file mode 100644 index 661e8c2ce0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/OrderingComposite.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.CollectionMapping; -import org.eclipse.jpt.jpa.core.context.Orderable; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Ordering -------------------------------------------------------------- | - * | | | | - * | | o None | | - * | | | | - * | | o Primary Key | | - * | | | | - * | | o Custom | | - * | | ------------------------------------------------------------------- | | - * | | | I | | | - * | | ------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see CollectionMapping - * @see ManyToManyMappingComposite - A container of this pane - * @see OneToManyMappingComposite - A container of this pane - * - * @version 3.0 - * @since 1.0 - */ -public class OrderingComposite extends AbstractOrderingComposite -{ - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OrderingComposite(Pane<? extends CollectionMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IMultiRelationshipMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrderingComposite(PropertyValueModel<? extends CollectionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - PropertyValueModel<Orderable> orderableHolder = buildOrderableHolder(); - - container = addCollapsibleSection( - container, - JptUiDetailsMessages.OrderingComposite_orderingGroup - ); - - // No Ordering radio button - addRadioButton( - container, - JptUiDetailsMessages.OrderingComposite_none, - buildNoOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_NO_ORDERING - ); - - // Order by Primary Key radio button - addRadioButton( - container, - JptUiDetailsMessages.OrderingComposite_primaryKey, - buildPrimaryKeyOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_PRIMARY_KEY_ORDERING - ); - - // Custom Ordering radio button - addRadioButton( - container, - JptUiDetailsMessages.OrderingComposite_custom, - buildCustomOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_CUSTOM_ORDERING - ); - - // Custom Ordering text field - addText( - addSubPane(container, 0, 16), - buildSpecifiedOrderByHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY, - buildCustomOrderingHolder(orderableHolder) - ); - } - - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeDetailsPage.java deleted file mode 100644 index 9f23f7f924..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeDetailsPage.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.Tracing; -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.model.value.FilteringPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -/** - * The abstract definition of the details page responsible to show the - * information for an persistent attribute. - * - * @see PersistentAttribute - * - * @version 2.2 - * @since 1.0 - */ -public abstract class PersistentAttributeDetailsPage<A extends ReadOnlyPersistentAttribute> - extends AbstractJpaDetailsPage<A> -{ - private Map<String, JpaComposite> mappingComposites; - private PageBook mappingPageBook; - - private PropertyValueModel<AttributeMapping> mappingHolder; - - /** - * Creates a new <code>PersistentAttributeDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected PersistentAttributeDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - - - @Override - protected void initialize() { - super.initialize(); - this.mappingComposites = new HashMap<String, JpaComposite>(); - } - - protected PageBook buildMappingPageBook(Composite parent) { - this.mappingPageBook = new PageBook(parent, SWT.NONE); - this.mappingPageBook.showPage(this.addLabel(this.mappingPageBook, "")); //$NON-NLS-1$ - - GridData gridData = new GridData(); - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.TOP; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - - this.mappingPageBook.setLayoutData(gridData); - - this.mappingHolder = this.buildMappingHolder(); - new ControlSwitcher(this.mappingHolder, this.buildPaneTransformer(), this.mappingPageBook); - - return this.mappingPageBook; - } - - private Transformer<AttributeMapping, Control> buildPaneTransformer() { - return new Transformer<AttributeMapping, Control>() { - public Control transform(AttributeMapping attributeMapping) { - if (attributeMapping == null) { - return null; - } - return getMappingComposite(attributeMapping.getKey()).getControl(); - } - }; - } - - protected JpaComposite getMappingComposite(String key) { - JpaComposite composite = this.mappingComposites.get(key); - if (composite != null) { - return composite; - } - - composite = buildMappingComposite(this.mappingPageBook, key); - - if (composite != null) { - this.mappingComposites.put(key, composite); - } - - return composite; - } - - protected JpaComposite buildMappingComposite(PageBook pageBook, String key) { - return getJpaPlatformUi().buildAttributeMappingComposite( - getSubject().getResourceType(), - key, - pageBook, - buildMappingHolder(key), - getWidgetFactory()); - } - - private PropertyValueModel<AttributeMapping> buildMappingHolder(final String key) { - return new FilteringPropertyValueModel<AttributeMapping>( - this.mappingHolder, - buildMappingFilter(key) - ); - } - - private Filter<AttributeMapping> buildMappingFilter(String mappingKey) { - return new MappingFilter(mappingKey); - } - - - private WritablePropertyValueModel<AttributeMapping> buildMappingHolder() { - return new PropertyAspectAdapter<A, AttributeMapping>( - getSubjectHolder(), - PersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY, - PersistentAttribute.MAPPING_PROPERTY) - { - @Override - protected AttributeMapping buildValue_() { - return this.subject.getMapping(); - } - }; - } - - @Override - public void dispose() { - log(Tracing.UI_DETAILS_VIEW, "PersistentAttributeDetailsPage.dispose()"); //$NON-NLS-1$ - - for (JpaComposite mappingComposite : this.mappingComposites.values()) { - mappingComposite.dispose(); - } - this.mappingComposites.clear(); - super.dispose(); - } - - @Override - protected void log(String flag, String message) { - super.log(flag, message); - - if (Tracing.UI_DETAILS_VIEW.equals(flag) && - Tracing.booleanDebugOption(Tracing.UI_DETAILS_VIEW)) - { - Tracing.log(message); - } - } - - private class MappingFilter implements Filter<AttributeMapping> { - private String mappingKey; - - MappingFilter(String mappingKey) { - super(); - this.mappingKey = mappingKey; - } - - public boolean accept(AttributeMapping mapping) { - return (mapping == null || this.mappingKey == null) || this.mappingKey.equals(mapping.getKey()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java deleted file mode 100644 index 01ce1c600c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.UnsupportedOrmMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * This "Map As" composite is responsible for showing the mapping name and - * mapping type for an attribute. - * - * @see JavaPersistentAttributeMapAsComposite - * @see OrmPersistentAttributeMapAsComposite - */ -public class PersistentAttributeMapAsComposite - extends MapAsComposite<ReadOnlyPersistentAttribute> -{ - /** - * Creates a new <code>PersistentAttributeMapAsComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistentAttributeMapAsComposite( - Pane<? extends ReadOnlyPersistentAttribute> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected String getMappingKey() { - return getSubject().getMappingKey(); - } - - @Override - protected MappingChangeHandler buildMappingChangeHandler() { - return new MappingChangeHandler() { - - public String getLabelText() { - String mappingKey = getMappingKey(); - - if (mappingKey != MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY) { - return JptUiDetailsMessages.MapAsComposite_mappedAttributeText; - } - if (getSubject().isVirtual()) { - return JptUiDetailsMessages.MapAsComposite_virtualAttributeText; - } - - return JptUiDetailsMessages.MapAsComposite_unmappedAttributeText; - } - - public String getMappingText() { - String mappingKey = getMappingKey(); - - if (mappingKey == null) { - return JptUiDetailsMessages.MapAsComposite_changeMappingType; - } - - return getSubject().getMapping().isDefault() ? - getDefaultDefinition(getSubject().getDefaultMappingKey()).getLinkLabel() : - getMappingUiDefinition(mappingKey).getLinkLabel(); - } - - public void morphMapping(MappingUiDefinition definition) { - ((PersistentAttribute) getSubject()).setMappingKey(definition.getKey()); - } - - public String getName() { - return getSubject().getName(); - } - - public Iterator<? extends MappingUiDefinition<? extends ReadOnlyPersistentAttribute, ?>> mappingUiDefinitions() { - return attributeMappingUiDefinitions(); - } - }; - } - - protected Iterator<? extends MappingUiDefinition<? extends ReadOnlyPersistentAttribute, ?>> attributeMappingUiDefinitions() { - return getJpaPlatformUi().attributeMappingUiDefinitions(getSubject().getResourceType()); - } - - @Override - protected DefaultMappingUiDefinition getDefaultDefinition() { - return getDefaultDefinition(getSubject().getDefaultMappingKey()); - } - - @Override - protected DefaultMappingUiDefinition getDefaultDefinition(String mappingKey) { - return getJpaPlatformUi().getDefaultAttributeMappingUiDefinition(getSubject().getMapping().getResourceType(), mappingKey); - } - - @Override - protected MappingUiDefinition getMappingUiDefinition(String mappingKey) { - MappingUiDefinition definition = super.getMappingUiDefinition(mappingKey); - return (definition != null) ? definition : UnsupportedOrmMappingUiDefinition.instance(); - } - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(ReadOnlyPersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY); - propertyNames.add(ReadOnlyPersistentAttribute.MAPPING_PROPERTY); - propertyNames.add(ReadOnlyPersistentAttribute.NAME_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - - if (propertyName == ReadOnlyPersistentAttribute.MAPPING_PROPERTY || - propertyName == ReadOnlyPersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY || - propertyName == ReadOnlyPersistentAttribute.NAME_PROPERTY) { - - updateDescription(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeDetailsPage.java deleted file mode 100644 index e9402d8a6a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeDetailsPage.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 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.jpa.ui.internal.details; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.Tracing; -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.model.value.FilteringPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -/** - * The abstract definition of the details page responsible to show the - * information for an persistent type. - * - * @see PersistentType - * - * @version 2.2 - * @since 1.0 - */ -@SuppressWarnings("nls") -public class PersistentTypeDetailsPage extends AbstractJpaDetailsPage<PersistentType> -{ - private Map<String, JpaComposite> mappingComposites; - private PageBook mappingPageBook; - private PropertyValueModel<TypeMapping> mappingHolder; - - /** - * Creates a new <code>PersistentTypeDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public PersistentTypeDetailsPage(Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - - @Override - protected void initialize() { - super.initialize(); - this.mappingComposites = new HashMap<String, JpaComposite>(); - } - - @Override - protected void initializeLayout(Composite container) { - - // Map As composite - new PersistentTypeMapAsComposite( - this, - addSubPane(container, 0, 0, 5, 0) - ); - - // Type properties page - buildMappingPageBook(container); - } - - protected PageBook buildMappingPageBook(Composite parent) { - - this.mappingPageBook = new PageBook(parent, SWT.NONE); - this.mappingPageBook.showPage(this.addLabel(this.mappingPageBook, "")); - - GridData gridData = new GridData(); - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.TOP; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - - this.mappingPageBook.setLayoutData(gridData); - - this.mappingHolder = this.buildMappingHolder(); - new ControlSwitcher(this.mappingHolder, this.buildPaneTransformer(), this.mappingPageBook); - - return this.mappingPageBook; - } - - private Transformer<TypeMapping, Control> buildPaneTransformer() { - return new Transformer<TypeMapping, Control>() { - public Control transform(TypeMapping typeMapping) { - if (typeMapping == null) { - return null; - } - return getMappingComposite(typeMapping.getKey()).getControl(); - } - }; - } - - protected PropertyValueModel<TypeMapping> buildMappingHolder(String key) { - return new FilteringPropertyValueModel<TypeMapping>( - this.mappingHolder, - buildMappingFilter(key) - ); - } - - private PropertyAspectAdapter<PersistentType, TypeMapping> buildMappingHolder() { - return new PropertyAspectAdapter<PersistentType, TypeMapping>(getSubjectHolder(), PersistentType.MAPPING_PROPERTY) { - @Override - protected TypeMapping buildValue_() { - return this.subject.getMapping(); - } - }; - } - - private Filter<TypeMapping> buildMappingFilter(final String key) { - return new Filter<TypeMapping>() { - public boolean accept(TypeMapping mapping) { - return (mapping == null || key == null) || key.equals(mapping.getKey()); - } - }; - } - - - private JpaComposite getMappingComposite(String key) { - JpaComposite mappingComposite = this.mappingComposites.get(key); - if (mappingComposite != null) { - return mappingComposite; - } - - mappingComposite = buildMappingComposite(this.mappingPageBook, key); - - if (mappingComposite != null) { - this.mappingComposites.put(key, mappingComposite); - } - - return mappingComposite; - } - - protected JpaComposite buildMappingComposite(PageBook pageBook, String key) { - return getJpaPlatformUi(). - buildTypeMappingComposite( - getSubject().getResourceType(), - key, - pageBook, - buildMappingHolder(key), - getWidgetFactory()); - } - - @Override - public void dispose() { - log(Tracing.UI_DETAILS_VIEW, "PersistentTypeDetailsPage.dispose()"); - - for (JpaComposite mappingComposite : this.mappingComposites.values()) { - mappingComposite.dispose(); - } - this.mappingComposites.clear(); - super.dispose(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java deleted file mode 100644 index c1a29c5066..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -/** - * This "Map As" composite is responsible for showing the mapping name and - * mapping type for a type. - * - * @see JavaPersistentTypeMapAsComposite - * @see OrmPersistentTypeMapAsComposite - * - * @version 2.2 - * @since 2.0 - */ -public class PersistentTypeMapAsComposite - extends MapAsComposite<PersistentType> -{ - /** - * Creates a new <code>PersistentTypeMapAsComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistentTypeMapAsComposite( - Pane<? extends PersistentType> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected String getMappingKey() { - return getSubject().getMappingKey(); - } - - @Override - protected MappingChangeHandler buildMappingChangeHandler() { - return new MappingChangeHandler() { - - public String getLabelText() { - String mappingKey = getMappingKey(); - - if (mappingKey != null) { - return JptUiDetailsMessages.MapAsComposite_mappedTypeText; - } - - return JptUiDetailsMessages.MapAsComposite_unmappedTypeText; - } - - public String getMappingText() { - String mappingKey = getMappingKey(); - - if (mappingKey == null) { - return JptUiDetailsMessages.MapAsComposite_changeMappingType; - } - - return getMappingUiDefinition(mappingKey).getLinkLabel(); - } - - public void morphMapping(MappingUiDefinition definition) { - getSubject().setMappingKey(definition.getKey()); - } - - public String getName() { - return getSubject().getSimpleName(); - } - - public Iterator<? extends MappingUiDefinition<? extends PersistentType, ?>> mappingUiDefinitions() { - return typeMappingUiDefinitions(); - } - }; - } - - /** - * Retrieves the list of definitions that are registered with the JPT plugin. - * - * @return The supported types of mapping - */ - protected Iterator<? extends MappingUiDefinition<? extends PersistentType, ?>> typeMappingUiDefinitions() { - return getJpaPlatformUi().typeMappingUiDefinitions(getSubject().getResourceType()); - } - - @Override - protected DefaultMappingUiDefinition getDefaultDefinition() { - return getJpaPlatformUi().getDefaultTypeMappingUiDefinition(getSubject().getResourceType()); - } - - @Override - protected DefaultMappingUiDefinition getDefaultDefinition(String mappingKey) { - return getDefaultDefinition(); - } - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(PersistentType.MAPPING_PROPERTY); - propertyNames.add(PersistentType.NAME_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - - if (propertyName == PersistentType.MAPPING_PROPERTY || - propertyName == PersistentType.NAME_PROPERTY) { - - updateDescription(); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnDialog.java deleted file mode 100644 index 960b9843fb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnDialog.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * This dialog is used to either create or edit a primary key join column that - * is located on an entity. - * - * @see PrimaryKeyJoinColumn - * @see Entity - * @see PrimaryKeyJoinColumnStateObject - * @see BaseJoinColumnDialogPane - * - * @version 2.0 - * @since 2.0 - */ -public class PrimaryKeyJoinColumnDialog extends BaseJoinColumnDialog<PrimaryKeyJoinColumnStateObject> { - - /** - * Creates a new <code>PrimaryKeyJoinColumnDialog</code>. - * - * @param parent The parent shell - * @param entity The owner of the join column to create or where it is - * located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public PrimaryKeyJoinColumnDialog(Shell parent, - Entity entity, - PrimaryKeyJoinColumn joinColumn) { - - super(parent, entity, joinColumn); - } - - /* - * (non-Javadoc) - */ - @Override - protected DialogPane<PrimaryKeyJoinColumnStateObject> buildLayout(Composite container) { - return new BaseJoinColumnDialogPane<PrimaryKeyJoinColumnStateObject>( - getSubjectHolder(), - container - ); - } - - /* - * (non-Javadoc) - */ - @Override - protected PrimaryKeyJoinColumnStateObject buildStateObject() { - return new PrimaryKeyJoinColumnStateObject(getOwner(), getJoinColumn()); - } - - /* - * (non-Javadoc) - */ - @Override - protected String getDescriptionTitle() { - - if (getJoinColumn() == null) { - return JptUiDetailsMessages.PrimaryKeyJoinColumnDialog_addDescriptionTitle; - } - - return JptUiDetailsMessages.PrimaryKeyJoinColumnDialog_editDescriptionTitle; - } - - /* - * (non-Javadoc) - */ - @Override - public PrimaryKeyJoinColumn getJoinColumn() { - return (PrimaryKeyJoinColumn) super.getJoinColumn(); - } - - /* - * (non-Javadoc) - */ - @Override - protected Entity getOwner() { - return (Entity) super.getOwner(); - } - - /* - * (non-Javadoc) - */ - @Override - protected String getTitle() { - - if (getJoinColumn() == null) { - return JptUiDetailsMessages.PrimaryKeyJoinColumnDialog_addTitle; - } - - return JptUiDetailsMessages.PrimaryKeyJoinColumnDialog_editTitle; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableDialog.java deleted file mode 100644 index 257bc5f1ee..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableDialog.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * This dialog is used to either create or edit a primary key joing column that - * is within a secondary table. - * - * @see PrimaryKeyJoinColumn - * @see SecondaryTable - * @see BaseJoinColumnDialogPane - * @see PrimaryKeyJoinColumnInSecondaryTableStateObject - * - * @version 2.0 - * @since 2.0 - */ -public class PrimaryKeyJoinColumnInSecondaryTableDialog extends BaseJoinColumnDialog<PrimaryKeyJoinColumnInSecondaryTableStateObject> { - - /** - * Creates a new <code>PrimaryKeyJoinColumnInSecondaryTableDialog</code>. - * - * @param parent The parent shell - * @param secondaryTable The owner of the join column to create or where it - * is located - * @param joinColumn Either the join column to edit or <code>null</code> if - * this state object is used to create a new one - */ - public PrimaryKeyJoinColumnInSecondaryTableDialog(Shell parent, - SecondaryTable secondaryTable, - PrimaryKeyJoinColumn joinColumn) { - - super(parent, secondaryTable, joinColumn); - } - - /* - * (non-Javadoc) - */ - @Override - protected DialogPane<PrimaryKeyJoinColumnInSecondaryTableStateObject> buildLayout(Composite container) { - return new BaseJoinColumnDialogPane<PrimaryKeyJoinColumnInSecondaryTableStateObject>( - getSubjectHolder(), - container - ); - } - - /* - * (non-Javadoc) - */ - @Override - protected PrimaryKeyJoinColumnInSecondaryTableStateObject buildStateObject() { - return new PrimaryKeyJoinColumnInSecondaryTableStateObject( - getOwner(), - getJoinColumn() - ); - } - - /* - * (non-Javadoc) - */ - @Override - protected String getDescriptionTitle() { - - if (getJoinColumn() == null) { - return JptUiDetailsMessages.PrimaryKeyJoinColumnInSecondaryTableDialog_addDescriptionTitle; - } - - return JptUiDetailsMessages.PrimaryKeyJoinColumnInSecondaryTableDialog_editDescriptionTitle; - } - - /* - * (non-Javadoc) - */ - @Override - public PrimaryKeyJoinColumn getJoinColumn() { - return (PrimaryKeyJoinColumn) super.getJoinColumn(); - } - - /* - * (non-Javadoc) - */ - @Override - protected SecondaryTable getOwner() { - return (SecondaryTable) super.getOwner(); - } - - /* - * (non-Javadoc) - */ - @Override - protected String getTitle() { - - if (getJoinColumn() == null) { - return JptUiDetailsMessages.PrimaryKeyJoinColumnInSecondaryTableDialog_addTitle; - } - - return JptUiDetailsMessages.PrimaryKeyJoinColumnInSecondaryTableDialog_editTitle; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableStateObject.java deleted file mode 100644 index 21d1b0a915..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableStateObject.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.jpt.jpa.db.Table; - -/** - * The state object used to create or edit a primary key join column on an - * secondary table. - * - * @see PrimaryKeyJoinColumn - * @see SecondaryTable - * @see PrimaryKeyJoinColumnInSecondaryTableDialog - * - * @version 2.0 - * @since 2.0 - */ -public class PrimaryKeyJoinColumnInSecondaryTableStateObject extends BaseJoinColumnStateObject -{ - /** - * Creates a new <code>PrimaryKeyJoinColumnInSecondaryTableStateObject</code>. - * - * @param secondaryTable The owner of the join column to create or where it - * is located - * @param joinColumn The join column to edit or <code>null</code> if it is to - * create a new one - */ - public PrimaryKeyJoinColumnInSecondaryTableStateObject(SecondaryTable secondaryTable, - PrimaryKeyJoinColumn joinColumn) { - - super(secondaryTable, joinColumn); - } - - /* - * (non-Javadoc) - */ - @Override - public String getDefaultTable() { - return null; - } - - /* - * (non-Javadoc) - */ - @Override - public PrimaryKeyJoinColumn getJoinColumn() { - return (PrimaryKeyJoinColumn) super.getJoinColumn(); - } - - /* - * (non-Javadoc) - */ - @Override - public Table getNameTable() { - return getOwner().getDbTable(); - } - - /* - * (non-Javadoc) - */ - @Override - public SecondaryTable getOwner() { - return (SecondaryTable) super.getOwner(); - } - - /* (non-Javadoc) - */ - @Override - public Table getReferencedNameTable() { - return getOwner().getParent().getPrimaryDbTable(); - } - - /* - * (non-Javadoc) - */ - @Override - protected String getInitialTable() { - return getOwner().getName(); - } - - /* - * (non-Javadoc) - */ - @Override - public ListIterator<String> tables() { - return new SingleElementListIterator<String>(getInitialTable()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnJoiningStrategyPane.java deleted file mode 100644 index acb1c3337e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnJoiningStrategyPane.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Primary key join columns ______________________________________________ | - * | | (no actual content) | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link PrimaryKeyJoinColumnRelationship} - * @see {@link PrimaryKeyJoinColumnRelationshipStrategy} - * @see {@link OneToOneJoiningStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class PrimaryKeyJoinColumnJoiningStrategyPane - extends AbstractJoiningStrategyPane - <PrimaryKeyJoinColumnRelationship, PrimaryKeyJoinColumnRelationshipStrategy> -{ - public PrimaryKeyJoinColumnJoiningStrategyPane( - Pane<? extends PrimaryKeyJoinColumnRelationship> parentPane, - Composite parent) { - super(parentPane, parent); - } - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return buildUsesPrimaryKeyJoinColumnJoiningStrategyHolder(getSubjectHolder()); - } - - protected PropertyValueModel<PrimaryKeyJoinColumnRelationshipStrategy> buildPrimaryKeyJoinColumnJoiningStrategyHolder() { - return new PropertyAspectAdapter - <PrimaryKeyJoinColumnRelationship, PrimaryKeyJoinColumnRelationshipStrategy>( - getSubjectHolder()) { - @Override - protected PrimaryKeyJoinColumnRelationshipStrategy buildValue_() { - return this.subject.getPrimaryKeyJoinColumnStrategy(); - } - }; - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - return null; - } - - public static WritablePropertyValueModel<Boolean> buildUsesPrimaryKeyJoinColumnJoiningStrategyHolder(PropertyValueModel<? extends PrimaryKeyJoinColumnRelationship> subjectHolder) { - return new PropertyAspectAdapter<PrimaryKeyJoinColumnRelationship, Boolean>( - subjectHolder, ReadOnlyRelationship.STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.strategyIsPrimaryKeyJoinColumn()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setStrategyToPrimaryKeyJoinColumn(); - } - //value == FALSE - selection of another radio button causes this strategy to get unset - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnStateObject.java deleted file mode 100644 index 4f1e8f9b8a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnStateObject.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.db.Table; - -/** - * The state object used to create or edit a primary key join column on an - * entity. - * - * @see PrimaryKeyJoinColumn - * @see Entity - * @see PrimaryKeyJoinColumnDialog - * @see PrimaryKeyJoinColumnDialogPane - * - * @version 2.0 - * @since 2.0 - */ -public class PrimaryKeyJoinColumnStateObject extends BaseJoinColumnStateObject -{ - /** - * Creates a new <code>PrimaryKeyJoinColumnStateObject</code>. - * - * @param entity The owner of the join column to create or where it is - * located - * @param joinColumn The join column to edit or <code>null</code> if this is - * used to create a new one - */ - public PrimaryKeyJoinColumnStateObject(Entity entity, - PrimaryKeyJoinColumn joinColumn) { - super(entity, joinColumn); - } - - /* - * (non-Javadoc) - */ - @Override - public String getDefaultTable() { - return null; - } - - /* - * (non-Javadoc) - */ - @Override - public PrimaryKeyJoinColumn getJoinColumn() { - return (PrimaryKeyJoinColumn) super.getJoinColumn(); - } - - /* - * (non-Javadoc) - */ - @Override - public Table getNameTable() { - return getOwner().getPrimaryDbTable(); - } - - /* - * (non-Javadoc) - */ - @Override - public Entity getOwner() { - return (Entity) super.getOwner(); - } - - /* - * (non-Javadoc) - */ - @Override - public Table getReferencedNameTable() { - Entity parentEntity = getOwner().getParentEntity(); - return (parentEntity == null) ? getOwner().getPrimaryDbTable() : parentEntity.getPrimaryDbTable(); - } - - /* - * (non-Javadoc) - */ - @Override - protected String getInitialTable() { - return getOwner().getPrimaryTableName(); - } - - /* - * (non-Javadoc) - */ - @Override - public ListIterator<String> tables() { - return new SingleElementListIterator<String>(getInitialTable()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java deleted file mode 100644 index 26b2fd287d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java +++ /dev/null @@ -1,414 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlySecondaryTable; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Join Columns ---------------------------------------------------------- | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | AddRemoveListPane | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see SecondaryTable - * @see AddRemoveListPane - * - * @version 2.0 - * @since 1.0 - */ -public class PrimaryKeyJoinColumnsInSecondaryTableComposite extends Pane<ReadOnlySecondaryTable> -{ - private WritablePropertyValueModel<ReadOnlyPrimaryKeyJoinColumn> joinColumnHolder; - - /** - * Creates a new <code>PrimaryKeyJoinColumnsInSecondaryTableComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public PrimaryKeyJoinColumnsInSecondaryTableComposite(Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlySecondaryTable> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - /** - * Creates a new <code>PrimaryKeyJoinColumnsInSecondaryTableComposite</code>. - * - * @param subjectHolder The holder of the subject <code>ISecondaryTable</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public PrimaryKeyJoinColumnsInSecondaryTableComposite(PropertyValueModel<? extends ReadOnlySecondaryTable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - void addJoinColumn(PrimaryKeyJoinColumnInSecondaryTableStateObject stateObject) { - - SecondaryTable secondaryTable = stateObject.getOwner(); - int index = secondaryTable.specifiedPrimaryKeyJoinColumnsSize(); - - PrimaryKeyJoinColumn joinColumn = secondaryTable.addSpecifiedPrimaryKeyJoinColumn(index); - stateObject.updateJoinColumn(joinColumn); - } - - void addPrimaryKeyJoinColumn() { - - PrimaryKeyJoinColumnInSecondaryTableDialog dialog = - new PrimaryKeyJoinColumnInSecondaryTableDialog(getShell(), (SecondaryTable) getSubject(), null); - - dialog.openDialog(buildAddPrimaryKeyJoinColumnPostExecution()); - } - - private PostExecution<PrimaryKeyJoinColumnInSecondaryTableDialog> buildAddPrimaryKeyJoinColumnPostExecution() { - return new PostExecution<PrimaryKeyJoinColumnInSecondaryTableDialog>() { - public void execute(PrimaryKeyJoinColumnInSecondaryTableDialog dialog) { - if (dialog.wasConfirmed()) { - addJoinColumn(dialog.getSubject()); - } - } - }; - } - - private PropertyValueModel<Boolean> buildControlBooleanHolder() { - return new TransformationPropertyValueModel<ReadOnlySecondaryTable, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(ReadOnlySecondaryTable value) { - if (value == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - private PropertyValueModel<ReadOnlyPrimaryKeyJoinColumn> buildDefaultJoinColumnHolder() { - return new PropertyAspectAdapter<ReadOnlySecondaryTable, ReadOnlyPrimaryKeyJoinColumn>(getSubjectHolder(), ReadOnlySecondaryTable.DEFAULT_PRIMARY_KEY_JOIN_COLUMN) { - @Override - protected ReadOnlyPrimaryKeyJoinColumn buildValue_() { - return this.subject.getDefaultPrimaryKeyJoinColumn(); - } - }; - } - - private ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildDefaultJoinColumnListHolder() { - return new PropertyListValueModelAdapter<ReadOnlyPrimaryKeyJoinColumn>( - buildDefaultJoinColumnHolder() - ); - } - - private PostExecution<PrimaryKeyJoinColumnInSecondaryTableDialog> buildEditPrimaryKeyJoinColumnPostExecution() { - return new PostExecution<PrimaryKeyJoinColumnInSecondaryTableDialog>() { - public void execute(PrimaryKeyJoinColumnInSecondaryTableDialog dialog) { - if (dialog.wasConfirmed()) { - editPrimaryKeyJoinColumn(dialog.getSubject()); - } - } - }; - } - - String buildJoinColumnLabel(ReadOnlyPrimaryKeyJoinColumn joinColumn) { - - if (joinColumn.isDefault()) { - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - if (joinColumn.getSpecifiedName() == null) { - if (joinColumn.getSpecifiedReferencedColumnName() == null) { - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsBothDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsFirstDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - if (joinColumn.getSpecifiedReferencedColumnName() == null) { - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParamsSecDefault, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - return NLS.bind( - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_mappingBetweenTwoParams, - joinColumn.getName(), - joinColumn.getReferencedColumnName() - ); - } - - private ILabelProvider buildJoinColumnsListLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - ReadOnlyPrimaryKeyJoinColumn joinColumn = (ReadOnlyPrimaryKeyJoinColumn) element; - return buildJoinColumnLabel(joinColumn); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - private AddRemovePane.Adapter buildPrimaryKeyJoinColumnAdapter() { - return new AddRemovePane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addPrimaryKeyJoinColumn(); - } - - @Override - public boolean hasOptionalButton() { - return true; - } - - @Override - public String optionalButtonText() { - return JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_edit; - } - - @Override - public void optionOnSelection(ObjectListSelectionModel listSelectionModel) { - editPrimaryKeyJoinColumn(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - removePrimaryKeyJoinColumn(listSelectionModel); - } - }; - } - - private WritablePropertyValueModel<ReadOnlyPrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnHolder() { - return new SimplePropertyValueModel<ReadOnlyPrimaryKeyJoinColumn>(); - } - - private ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListHolder() { - List<ListValueModel<ReadOnlyPrimaryKeyJoinColumn>> list = new ArrayList<ListValueModel<ReadOnlyPrimaryKeyJoinColumn>>(); - list.add(buildSpecifiedJoinColumnsListHolder()); - list.add(buildDefaultJoinColumnListHolder()); - return new CompositeListValueModel<ListValueModel<ReadOnlyPrimaryKeyJoinColumn>, ReadOnlyPrimaryKeyJoinColumn>(list); - } - - private ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListModel() { - return new ItemPropertyListValueModelAdapter<ReadOnlyPrimaryKeyJoinColumn>( - buildPrimaryKeyJoinColumnsListHolder(), - ReadOnlyNamedColumn.SPECIFIED_NAME_PROPERTY, - ReadOnlyNamedColumn.DEFAULT_NAME_PROPERTY, - ReadOnlyBaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, - ReadOnlyBaseJoinColumn.DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY - ); - } - - ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<ReadOnlySecondaryTable, ReadOnlyPrimaryKeyJoinColumn>(getSubjectHolder(), ReadOnlySecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<ReadOnlyPrimaryKeyJoinColumn> listIterator_() { - return new SuperListIteratorWrapper<ReadOnlyPrimaryKeyJoinColumn>(subject.specifiedPrimaryKeyJoinColumns()); - } - - @Override - protected int size_() { - return subject.specifiedPrimaryKeyJoinColumnsSize(); - } - }; - } - - void editPrimaryKeyJoinColumn(ObjectListSelectionModel listSelectionModel) { - - PrimaryKeyJoinColumn joinColumn = (PrimaryKeyJoinColumn) listSelectionModel.selectedValue(); - - PrimaryKeyJoinColumnInSecondaryTableDialog dialog = - new PrimaryKeyJoinColumnInSecondaryTableDialog( - getShell(), - (SecondaryTable) getSubject(), - joinColumn - ); - - dialog.openDialog(buildEditPrimaryKeyJoinColumnPostExecution()); - } - - void editPrimaryKeyJoinColumn(PrimaryKeyJoinColumnInSecondaryTableStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - @Override - protected void initialize() { - super.initialize(); - joinColumnHolder = buildPrimaryKeyJoinColumnHolder(); - } - - @Override - protected void initializeLayout(Composite container) { - - // Primary Key Join Columns group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn - ); - - // Override Default check box - addCheckBox( - addSubPane(groupPane, 8), - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns, - buildOverrideDefaultJoinColumnHolder(), - null, - buildControlBooleanHolder() - ); - - // Primary Key Join Columns list pane - AddRemoveListPane<ReadOnlySecondaryTable> joinColumnsPane = new AddRemoveListPane<ReadOnlySecondaryTable>( - this, - groupPane, - buildPrimaryKeyJoinColumnAdapter(), - buildPrimaryKeyJoinColumnsListModel(), - joinColumnHolder, - buildJoinColumnsListLabelProvider(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS - ); - - installPrimaryKeyJoinColumnListPaneEnabler(joinColumnsPane); - } - - private void installPrimaryKeyJoinColumnListPaneEnabler(AddRemoveListPane<ReadOnlySecondaryTable> pkJoinColumnListPane) { - - new PaneEnabler( - buildOverrideDefaultJoinColumnHolder(), - pkJoinColumnListPane - ); - } - - void removePrimaryKeyJoinColumn(ObjectListSelectionModel listSelectionModel) { - int[] selectedIndices = listSelectionModel.selectedIndices(); - - for (int index = selectedIndices.length; --index >= 0; ) { - ((SecondaryTable) getSubject()).removeSpecifiedPrimaryKeyJoinColumn(selectedIndices[index]); - } - } - - void updateJoinColumns(boolean selected) { - - if (isPopulating()) { - return; - } - - setPopulating(true); - - try { - SecondaryTable secondaryTable = (SecondaryTable) getSubject(); - - // Add a join column by creating a specified one using the default - // one if it exists - if (selected) { - - PrimaryKeyJoinColumn defaultJoinColumn = secondaryTable.getDefaultPrimaryKeyJoinColumn(); - - if (defaultJoinColumn != null) { - String columnName = defaultJoinColumn.getDefaultName(); - String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName(); - - PrimaryKeyJoinColumn pkJoinColumn = secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0); - pkJoinColumn.setSpecifiedName(columnName); - pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName); - - joinColumnHolder.setValue(pkJoinColumn); - } - } - else { - for (int index = secondaryTable.specifiedPrimaryKeyJoinColumnsSize(); --index >= 0; ) { - secondaryTable.removeSpecifiedPrimaryKeyJoinColumn(index); - } - } - } - finally { - setPopulating(false); - } - } - - private class OverrideDefaultJoinColumnHolder extends ListPropertyValueModelAdapter<Boolean> - implements WritablePropertyValueModel<Boolean> { - - public OverrideDefaultJoinColumnHolder() { - super(buildSpecifiedJoinColumnsListHolder()); - } - - @Override - protected Boolean buildValue() { - return Boolean.valueOf(this.buildValue_()); - } - - protected boolean buildValue_() { - ReadOnlySecondaryTable table = getSubject(); - return (table != null) && ! table.isVirtual() && listHolder.size() > 0; - } - - public void setValue(Boolean value) { - updateJoinColumns(value.booleanValue()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java deleted file mode 100644 index 6c3c949a65..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java +++ /dev/null @@ -1,313 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.NamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -/** - * This pane shows the list of named queries and named native queries. - * <p> - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | NamedQueryPropertyComposite or NamedNativeQueryPropertyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see Query - * @see NamedNativeQuery - * @see NamedQuery - * @see AbstractEntityComposite - The parent container - * @see NamedNativeQueryPropertyComposite - * @see NamedQueryPropertyComposite - * - * @version 2.0 - * @since 2.0 - */ -public class QueriesComposite extends Pane<QueryContainer> -{ - private AddRemoveListPane<QueryContainer> listPane; - NamedNativeQueryPropertyComposite namedNativeQueryPane; - NamedQueryPropertyComposite<? extends NamedQuery> namedQueryPane; - private WritablePropertyValueModel<Query> queryHolder; - - - public QueriesComposite( - Pane<?> parentPane, - PropertyValueModel<? extends QueryContainer> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - void addQuery() { - addQueryFromDialog(buildAddQueryDialog()); - } - - protected AddQueryDialog buildAddQueryDialog() { - return new AddQueryDialog(getShell(), this.getSubject().getPersistenceUnit()); - } - - protected void addQueryFromDialog(AddQueryDialog dialog) { - if (dialog.open() != Window.OK) { - return; - } - String queryType = dialog.getQueryType(); - Query query; - if (queryType == AddQueryDialog.NAMED_QUERY) { - query = this.getSubject().addNamedQuery(); - } - else if (queryType == AddQueryDialog.NAMED_NATIVE_QUERY) { - query = this.getSubject().addNamedNativeQuery(); - } - else { - throw new IllegalArgumentException(); - } - query.setName(dialog.getName()); - this.getQueryHolder().setValue(query);//so that it gets selected in the List for the user to edit - } - - private ListValueModel<Query> buildDisplayableQueriesListHolder() { - return new ItemPropertyListValueModelAdapter<Query>( - buildQueriesListHolder(), - Query.NAME_PROPERTY - ); - } - - private AddRemoveListPane<QueryContainer> addListPane(Composite container) { - - return new AddRemoveListPane<QueryContainer>( - this, - container, - buildQueriesAdapter(), - buildDisplayableQueriesListHolder(), - this.getQueryHolder(), - buildQueriesListLabelProvider(), - JpaHelpContextIds.MAPPING_NAMED_QUERIES - ); - } - - private ListValueModel<NamedNativeQuery> buildNamedNativeQueriesListHolder() { - return new ListAspectAdapter<QueryContainer, NamedNativeQuery>( - getSubjectHolder(), - QueryContainer.NAMED_NATIVE_QUERIES_LIST) - { - @Override - protected ListIterator<NamedNativeQuery> listIterator_() { - return this.subject.namedNativeQueries(); - } - - @Override - protected int size_() { - return this.subject.namedNativeQueriesSize(); - } - }; - } - - private PropertyValueModel<NamedNativeQuery> buildNamedNativeQueryHolder() { - return new TransformationPropertyValueModel<Query, NamedNativeQuery>(this.getQueryHolder()) { - @Override - protected NamedNativeQuery transform_(Query value) { - return (value instanceof NamedNativeQuery) ? (NamedNativeQuery) value : null; - } - }; - } - - private ListValueModel<NamedQuery> buildNamedQueriesListHolder() { - return new ListAspectAdapter<QueryContainer, NamedQuery>( - getSubjectHolder(), - QueryContainer.NAMED_QUERIES_LIST) - { - @Override - protected ListIterator<NamedQuery> listIterator_() { - return this.subject.namedQueries(); - } - - @Override - protected int size_() { - return this.subject.namedQueriesSize(); - } - }; - } - - private PropertyValueModel<NamedQuery> buildNamedQueryHolder() { - return new TransformationPropertyValueModel<Query, NamedQuery>(this.getQueryHolder()) { - @Override - protected NamedQuery transform_(Query value) { - return (value instanceof NamedQuery) ? (NamedQuery) value : null; - } - }; - } - - private Transformer<Query, Control> buildPaneTransformer() { - return new Transformer<Query, Control>() { - public Control transform(Query query) { - - if (query == null) { - return null; - } - - if (query instanceof NamedNativeQuery) { - return QueriesComposite.this.namedNativeQueryPane.getControl(); - } - - return QueriesComposite.this.namedQueryPane.getControl(); - } - }; - } - - private Adapter buildQueriesAdapter() { - - return new AddRemoveListPane.AbstractAdapter() { - - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addQuery(); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - if (item instanceof NamedQuery) { - getSubject().removeNamedQuery((NamedQuery) item); - } - else { - getSubject().removeNamedNativeQuery((NamedNativeQuery) item); - } - } - } - }; - } - - private ListValueModel<Query> buildQueriesListHolder() { - List<ListValueModel<? extends Query>> list = new ArrayList<ListValueModel<? extends Query>>(); - list.add(buildNamedQueriesListHolder()); - list.add(buildNamedNativeQueriesListHolder()); - return new CompositeListValueModel<ListValueModel<? extends Query>, Query>(list); - } - - private ILabelProvider buildQueriesListLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - Query query = (Query) element; - String name = query.getName(); - - if (name == null) { - int index = -1; - - if (query instanceof NamedQuery) { - index = CollectionTools.indexOf(getSubject().namedQueries(), query); - } - else { - index = CollectionTools.indexOf(getSubject().namedNativeQueries(), query); - } - - name = NLS.bind(JptUiDetailsMessages.QueriesComposite_displayString, Integer.valueOf(index)); - } - - return name; - } - }; - } - - private WritablePropertyValueModel<Query> buildQueryHolder() { - return new SimplePropertyValueModel<Query>(); - } - - @Override - public void enableWidgets(boolean enabled) { - super.enableWidgets(enabled); - this.listPane.enableWidgets(enabled); - } - - @Override - protected void initialize() { - super.initialize(); - this.queryHolder = buildQueryHolder(); - } - - @Override - protected void initializeLayout(Composite container) { - - // List pane - this.listPane = this.addListPane(container); - - // Property pane - PageBook pageBook = new PageBook(container, SWT.NULL); - pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // Named Query property pane - this.namedQueryPane = this.buildNamedQueryPropertyComposite(pageBook); - - // Named Native Query property pane - this.namedNativeQueryPane = new NamedNativeQueryPropertyComposite( - this, - this.buildNamedNativeQueryHolder(), - pageBook - ); - - installPaneSwitcher(pageBook); - } - - protected NamedQueryPropertyComposite<? extends NamedQuery> buildNamedQueryPropertyComposite(PageBook pageBook) { - return new NamedQueryPropertyComposite<NamedQuery>( - this, - this.buildNamedQueryHolder(), - pageBook - ); - } - - private void installPaneSwitcher(PageBook pageBook) { - new ControlSwitcher(this.getQueryHolder(), this.buildPaneTransformer(), pageBook); - } - - protected WritablePropertyValueModel<Query> getQueryHolder() { - return queryHolder; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueryHintsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueryHintsComposite.java deleted file mode 100644 index c1f21e2eeb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueryHintsComposite.java +++ /dev/null @@ -1,339 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveTablePane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.QueryHint; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | AddRemoveTablePane | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see Query - * @see QueryHint - * @see AddRemoveTablePane - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class QueryHintsComposite extends Pane<Query> -{ - private WritablePropertyValueModel<QueryHint> queryHintHolder; - - /** - * Creates a new <code>QueryHintsComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public QueryHintsComposite(Pane<? extends Query> parentPane, - Composite container) { - - super(parentPane, container); - } - - private PropertyValueModel<Boolean> buildPaneEnableHolder() { - return new TransformationPropertyValueModel<Query, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(Query query) { - return (query != null); - } - }; - } - - private Adapter buildQueryHintAdapter() { - return new AddRemoveTablePane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - QueryHint queryHint = getSubject().addHint(getSubject().getHintsSize()); - queryHintHolder.setValue(queryHint); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeHint((QueryHint) item); - } - } - }; - } - - private WritablePropertyValueModel<QueryHint> buildQueryHintHolder() { - return new SimplePropertyValueModel<QueryHint>(); - }; - - private ITableLabelProvider buildQueryHintLabelProvider() { - return new TableLabelProvider(); - } - - private ListValueModel<QueryHint> buildQueryHintListHolder() { - return new ListAspectAdapter<Query, QueryHint>(getSubjectHolder(), NamedQuery.HINTS_LIST) { - @Override - protected ListIterable<QueryHint> getListIterable() { - return subject.getHints(); - } - - @Override - protected int size_() { - return subject.getHintsSize(); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initialize() { - super.initialize(); - queryHintHolder = buildQueryHintHolder(); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - TablePane tablePane = new TablePane(container); - installPaneEnabler(tablePane); - } - - private PaneEnabler installPaneEnabler(TablePane tablePane) { - return new PaneEnabler(buildPaneEnableHolder(), tablePane); - } - - private static class QueryHintColumnAdapter implements ColumnAdapter<QueryHint> { - - static final int COLUMN_COUNT = 2; - static final int NAME_COLUMN_INDEX = 0; - static final int VALUE_COLUMN_INDEX = 1; - - private WritablePropertyValueModel<String> buildNameHolder(QueryHint subject) { - return new PropertyAspectAdapter<QueryHint, String>(QueryHint.NAME_PROPERTY, subject) { - @Override - protected String buildValue_() { - return subject.getName(); - } - - @Override - protected void setValue_(String value) { - subject.setName(value); - } - }; - } - - private WritablePropertyValueModel<?> buildValueHolder(QueryHint subject) { - return new PropertyAspectAdapter<QueryHint, String>(QueryHint.VALUE_PROPERTY, subject) { - @Override - protected String buildValue_() { - return subject.getValue(); - } - - @Override - protected void setValue_(String value) { - subject.setValue(value); - } - }; - } - - public WritablePropertyValueModel<?>[] cellModels(QueryHint subject) { - WritablePropertyValueModel<?>[] models = new WritablePropertyValueModel<?>[COLUMN_COUNT]; - models[NAME_COLUMN_INDEX] = buildNameHolder(subject); - models[VALUE_COLUMN_INDEX] = buildValueHolder(subject); - return models; - } - - public int columnCount() { - return COLUMN_COUNT; - } - - public String columnName(int columnIndex) { - - switch (columnIndex) { - case QueryHintColumnAdapter.NAME_COLUMN_INDEX: { - return JptUiDetailsMessages.QueryHintsComposite_nameColumn; - } - - case QueryHintColumnAdapter.VALUE_COLUMN_INDEX: { - return JptUiDetailsMessages.QueryHintsComposite_valueColumn; - } - - default: { - return null; - } - } - } - } - - private class TableLabelProvider extends LabelProvider - implements ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - - QueryHint queryHint = (QueryHint) element; - String value = ""; - - switch (columnIndex) { - case QueryHintColumnAdapter.NAME_COLUMN_INDEX: { - value = queryHint.getName(); - break; - } - - case QueryHintColumnAdapter.VALUE_COLUMN_INDEX: { - value = queryHint.getValue(); - break; - } - } - - if (value == null) { - value = ""; - } - - return value; - } - } - - private class TablePane extends AddRemoveTablePane<Query> { - - private TablePane(Composite parent) { - super(QueryHintsComposite.this, - parent, - buildQueryHintAdapter(), - buildQueryHintListHolder(), - queryHintHolder, - buildQueryHintLabelProvider()); - } - - private CellEditor[] buildCellEditors(Table table) { - return new CellEditor[] { - new TextCellEditor(table), - new TextCellEditor(table) - }; - } - - private ICellModifier buildCellModifier() { - return new ICellModifier() { - - public boolean canModify(Object element, String property) { - return true; - } - - public Object getValue(Object element, String property) { - QueryHint queryHint = (QueryHint) element; - String value = ""; - - if (property == QueryHint.NAME_PROPERTY) { - value = queryHint.getName(); - } - else if (property == QueryHint.VALUE_PROPERTY) { - value = queryHint.getValue(); - } - - if (value == null) { - value = ""; - } - - return value; - } - - public void modify(Object element, String property, Object value) { - QueryHint queryHint; - - if (element instanceof TableItem) { - TableItem tableItem = (TableItem) element; - queryHint = (QueryHint) tableItem.getData(); - } - else { - queryHint = (QueryHint) element; - } - - if (property == QueryHint.NAME_PROPERTY) { - queryHint.setName(value.toString()); - } - else if (property == QueryHint.VALUE_PROPERTY) { - queryHint.setValue(value.toString()); - } - } - }; - } - - @Override - protected ColumnAdapter<?> buildColumnAdapter() { - return new QueryHintColumnAdapter(); - } - - private String[] buildColumnProperties() { - return new String[] { - QueryHint.NAME_PROPERTY, - QueryHint.VALUE_PROPERTY - }; - } - - @Override - protected void initializeMainComposite(Composite container, - Adapter adapter, - ListValueModel<?> listHolder, - WritablePropertyValueModel<?> selectedItemHolder, - IBaseLabelProvider labelProvider, - String helpId) { - - super.initializeMainComposite( - container, - adapter, - listHolder, - selectedItemHolder, - labelProvider, - helpId - ); - - Table table = getMainControl(); - - TableViewer tableViewer = new TableViewer(table); - tableViewer.setCellEditors(buildCellEditors(table)); - tableViewer.setCellModifier(buildCellModifier()); - tableViewer.setColumnProperties(buildColumnProperties()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java deleted file mode 100644 index 371764dbd8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java +++ /dev/null @@ -1,436 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details; - -import java.util.Collection; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.ValueListAdapter; -import org.eclipse.jpt.common.utility.model.event.StateChangeEvent; -import org.eclipse.jpt.common.utility.model.listener.StateChangeListener; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyReferenceTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.ReferenceTable; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnsComposite.JoinColumnsEditor; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.TableCombo; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - - -public abstract class ReferenceTableComposite<T extends ReadOnlyReferenceTable> - extends Pane<T> -{ - protected Button overrideDefaultJoinColumnsCheckBox; - - protected JoinColumnsComposite<T> joinColumnsComposite; - - /** - * Creates a new <code>ReferenceTableComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - protected ReferenceTableComposite( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - /** - * Creates a new <code>ReferenceTableComposite</code>. - * - * @param subjectHolder The holder of the subject <code>CollectionTable2_0</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected ReferenceTableComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - protected void installJoinColumnsPaneEnabler(JoinColumnsComposite<T> pane) { - pane.installJoinColumnsPaneEnabler(new JoinColumnPaneEnablerHolder()); - } - - void addJoinColumn(T referenceTable) { - - JoinColumnInReferenceTableDialog dialog = - new JoinColumnInReferenceTableDialog(getShell(), referenceTable, null); - - dialog.openDialog(buildAddJoinColumnPostExecution()); - } - - void addJoinColumnFromDialog(JoinColumnInReferenceTableStateObject stateObject) { - JoinColumn joinColumn = ((ReferenceTable) getSubject()).addSpecifiedJoinColumn(); - stateObject.updateJoinColumn(joinColumn); - this.setSelectedJoinColumn(joinColumn); - } - - private void setSelectedJoinColumn(JoinColumn joinColumn) { - this.joinColumnsComposite.setSelectedJoinColumn(joinColumn); - } - - private PostExecution<JoinColumnInReferenceTableDialog> buildAddJoinColumnPostExecution() { - return new PostExecution<JoinColumnInReferenceTableDialog>() { - public void execute(JoinColumnInReferenceTableDialog dialog) { - if (dialog.wasConfirmed()) { - addJoinColumnFromDialog(dialog.getSubject()); - } - } - }; - } - - private PostExecution<JoinColumnInReferenceTableDialog> buildEditJoinColumnPostExecution() { - return new PostExecution<JoinColumnInReferenceTableDialog>() { - public void execute(JoinColumnInReferenceTableDialog dialog) { - if (dialog.wasConfirmed()) { - editJoinColumn(dialog.getSubject()); - } - } - }; - } - - protected JoinColumnsProvider buildJoinColumnsEditor() { - return new JoinColumnsProvider(); - } - - protected WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - ListValueModel<ReadOnlyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<T, ReadOnlyJoinColumn>(getSubjectHolder(), ReadOnlyReferenceTable.SPECIFIED_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<ReadOnlyJoinColumn> listIterator_() { - return new SuperListIteratorWrapper<ReadOnlyJoinColumn>(this.subject.specifiedJoinColumns()); - } - - @Override - protected int size_() { - return this.subject.specifiedJoinColumnsSize(); - } - }; - } - - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 10, groupBoxMargin); - } - - protected TableCombo<T> addTableCombo(Composite container) { - - return new TableCombo<T>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(ReadOnlyTable.DEFAULT_NAME_PROPERTY); - propertyNames.add(ReadOnlyTable.SPECIFIED_NAME_PROPERTY); - propertyNames.add(ReadOnlyTable.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(ReadOnlyTable.SPECIFIED_SCHEMA_PROPERTY); - propertyNames.add(ReadOnlyTable.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(ReadOnlyTable.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - if (propertyName == ReadOnlyTable.DEFAULT_SCHEMA_PROPERTY - || propertyName == ReadOnlyTable.SPECIFIED_SCHEMA_PROPERTY - || propertyName == ReadOnlyTable.DEFAULT_CATALOG_PROPERTY - || propertyName == ReadOnlyTable.SPECIFIED_CATALOG_PROPERTY ) { - repopulate(); - } - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultName(); - } - - @Override - protected void setValue(String value) { - ((ReferenceTable) this.getSubject()).setSpecifiedName(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedName(); - } - - @Override - protected Schema getDbSchema_() { - ReferenceTable table = this.getTable(); - return (table == null) ? null : table.getDbSchema(); - } - - protected ReferenceTable getTable() { - ReadOnlyReferenceTable table = this.getSubject(); - return (table instanceof ReferenceTable) ? (ReferenceTable) table : null; - } - }; - } - - protected SchemaCombo<T> addSchemaCombo(Composite container) { - - return new SchemaCombo<T>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(ReadOnlyTable.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(ReadOnlyTable.SPECIFIED_SCHEMA_PROPERTY); - propertyNames.add(ReadOnlyTable.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(ReadOnlyTable.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - if (propertyName == ReadOnlyTable.DEFAULT_CATALOG_PROPERTY - || propertyName == ReadOnlyTable.SPECIFIED_CATALOG_PROPERTY ) { - repopulate(); - } - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultSchema(); - } - - @Override - protected void setValue(String value) { - ((ReferenceTable) this.getSubject()).setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - ReferenceTable table = this.getTable(); - return (table == null) ? null : table.getDbSchemaContainer(); - } - - protected ReferenceTable getTable() { - ReadOnlyReferenceTable table = this.getSubject(); - return (table instanceof ReferenceTable) ? (ReferenceTable) table : null; - } - }; - } - - protected CatalogCombo<T> addCatalogCombo(Composite container) { - - return new CatalogCombo<T>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(ReadOnlyTable.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(ReadOnlyTable.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultCatalog(); - } - - @Override - protected void setValue(String value) { - ((ReferenceTable) this.getSubject()).setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedCatalog(); - } - }; - } - - void editJoinColumn(ReadOnlyJoinColumn joinColumn) { - - JoinColumnInReferenceTableDialog dialog = - new JoinColumnInReferenceTableDialog(getShell(), getSubject(), joinColumn); - - dialog.openDialog(buildEditJoinColumnPostExecution()); - } - - void editJoinColumn(JoinColumnInReferenceTableStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - void updateJoinColumns() { - if (this.isPopulating()) { - return; - } - - ReferenceTable referenceTable = (ReferenceTable) this.getSubject(); - if (referenceTable == null) { - return; - } - - boolean selected = this.overrideDefaultJoinColumnsCheckBox.getSelection(); - this.setPopulating(true); - - try { - if (selected) { - referenceTable.convertDefaultToSpecifiedJoinColumn(); - setSelectedJoinColumn(referenceTable.specifiedJoinColumns().next()); - } else { - for (int index = referenceTable.specifiedJoinColumnsSize(); --index >= 0; ) { - referenceTable.removeSpecifiedJoinColumn(index); - } - } - } finally { - this.setPopulating(false); - } - } - - class JoinColumnsProvider implements JoinColumnsEditor<T> { - - public void addJoinColumn(T subject) { - ReferenceTableComposite.this.addJoinColumn(subject); - } - - public ReadOnlyJoinColumn getDefaultJoinColumn(T subject) { - return subject.getDefaultJoinColumn(); - } - - public String getDefaultPropertyName() { - return ReadOnlyReferenceTable.DEFAULT_JOIN_COLUMN_PROPERTY; - } - - public void editJoinColumn(T subject, ReadOnlyJoinColumn joinColumn) { - ReferenceTableComposite.this.editJoinColumn(joinColumn); - } - - public boolean hasSpecifiedJoinColumns(T subject) { - return subject.hasSpecifiedJoinColumns(); - } - - public void removeJoinColumns(T subject, int[] selectedIndices) { - for (int index = selectedIndices.length; index-- > 0; ) { - ((ReferenceTable) subject).removeSpecifiedJoinColumn(selectedIndices[index]); - } - } - - public ListIterator<ReadOnlyJoinColumn> specifiedJoinColumns(T subject) { - return new SuperListIteratorWrapper<ReadOnlyJoinColumn>(subject.specifiedJoinColumns()); - } - - public int specifiedJoinColumnsSize(T subject) { - return subject.specifiedJoinColumnsSize(); - } - - public String getSpecifiedJoinColumnsListPropertyName() { - return ReadOnlyReferenceTable.SPECIFIED_JOIN_COLUMNS_LIST; - } - } - - - private class OverrideDefaultJoinColumnHolder extends ListPropertyValueModelAdapter<Boolean> - implements WritablePropertyValueModel<Boolean> { - - public OverrideDefaultJoinColumnHolder() { - super(buildSpecifiedJoinColumnsListHolder()); - } - - @Override - protected Boolean buildValue() { - return Boolean.valueOf(this.listHolder.size() > 0); - } - - public void setValue(Boolean value) { - updateJoinColumns(); - } - } - - - private class JoinColumnPaneEnablerHolder - extends CachingTransformationPropertyValueModel<T, Boolean> - { - private StateChangeListener stateChangeListener; - - - public JoinColumnPaneEnablerHolder() { - super( - new ValueListAdapter<T>( - new ReadOnlyWritablePropertyValueModelWrapper<T>(getSubjectHolder()), - ReadOnlyReferenceTable.SPECIFIED_JOIN_COLUMNS_LIST)); - this.stateChangeListener = buildStateChangeListener(); - } - - - private StateChangeListener buildStateChangeListener() { - return new StateChangeListener() { - public void stateChanged(StateChangeEvent event) { - valueStateChanged(); - } - }; - } - - void valueStateChanged() { - Object oldValue = this.cachedValue; - Object newValue = transformNew(this.valueHolder.getValue()); - firePropertyChanged(VALUE, oldValue, newValue); - } - - @Override - protected Boolean transform(T value) { - if (value == null) { - return Boolean.FALSE; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(T value) { - boolean virtual = ReferenceTableComposite.this.tableIsVirtual(value); - return Boolean.valueOf(! virtual && value.specifiedJoinColumnsSize() > 0); - } - - @Override - protected void engageModel() { - super.engageModel(); - this.valueHolder.addStateChangeListener(this.stateChangeListener); - } - - @Override - protected void disengageModel() { - this.valueHolder.removeStateChangeListener(this.stateChangeListener); - super.disengageModel(); - } - } - - protected abstract boolean tableIsVirtual(T referenceTable); -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/SecondaryTableDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/SecondaryTableDialog.java deleted file mode 100644 index 6bbf03d4a7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/SecondaryTableDialog.java +++ /dev/null @@ -1,450 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -/** - * Clients can use this dialog to prompt the user for SecondaryTable settings. - * Use the following once the dialog is closed: - * @see #getSelectedTable() - * @see #getSelectedCatalog() - * @see #getSelectedSchema() - */ -public class SecondaryTableDialog extends Dialog { - - private final JpaProject jpaProject; - - /** - * when creating a new SecondaryTable, 'secondaryTable' will be null - */ - private final SecondaryTable secondaryTable; - private final String defaultCatalog; - private final String defaultSchema; - - protected Combo tableCombo; - protected Combo catalogCombo; - protected Combo schemaCombo; - - // these values are set upon close - private String selectedTable; - private String selectedSchema; - private String selectedCatalog; - - - // ********** constructors ********** - - /** - * Use this constructor to create a new secondary table - */ - public SecondaryTableDialog(Shell parent, JpaProject jpaProject, String defaultCatalog, String defaultSchema) { - this(parent, jpaProject, null, defaultCatalog, defaultSchema); - } - - /** - * Use this constructor to edit an existing secondary table - */ - public SecondaryTableDialog(Shell parent, JpaProject jpaProject, SecondaryTable secondaryTable) { - this(parent, jpaProject, secondaryTable, secondaryTable.getDefaultCatalog(), secondaryTable.getDefaultSchema()); - } - - /** - * internal constructor - */ - protected SecondaryTableDialog(Shell parent, JpaProject jpaProject, SecondaryTable secondaryTable, String defaultCatalog, String defaultSchema) { - super(parent); - this.jpaProject = jpaProject; - this.secondaryTable = secondaryTable; - this.defaultCatalog = defaultCatalog; - this.defaultSchema = defaultSchema; - } - - - // ********** open ********** - - @Override - protected Point getInitialSize() { - Point size = super.getInitialSize(); - size.x = this.convertWidthInCharsToPixels(50); // ??? - return size; - } - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(this.getTitle()); - } - - protected String getTitle() { - return (this.secondaryTable == null) ? - JptUiDetailsMessages.SecondaryTableDialog_addSecondaryTable - : - JptUiDetailsMessages.SecondaryTableDialog_editSecondaryTable; - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - GridLayout gridLayout = (GridLayout) composite.getLayout(); - gridLayout.numColumns = 2; - - // table - Label tableLabel = new Label(composite, SWT.LEFT); - tableLabel.setText(JptUiDetailsMessages.SecondaryTableDialog_name); - GridData gridData = new GridData(); - tableLabel.setLayoutData(gridData); - - this.tableCombo = new Combo(composite, SWT.LEFT); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - this.tableCombo.setLayoutData(gridData); - - // catalog - Label catalogLabel = new Label(composite, SWT.LEFT); - catalogLabel.setText(JptUiDetailsMessages.SecondaryTableDialog_catalog); - gridData = new GridData(); - catalogLabel.setLayoutData(gridData); - - this.catalogCombo = new Combo(composite, SWT.LEFT); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - this.catalogCombo.setLayoutData(gridData); - - // schema - Label schemaLabel = new Label(composite, SWT.LEFT); - schemaLabel.setText(JptUiDetailsMessages.SecondaryTableDialog_schema); - gridData = new GridData(); - schemaLabel.setLayoutData(gridData); - - this.schemaCombo = new Combo(composite, SWT.LEFT); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - this.schemaCombo.setLayoutData(gridData); - - this.initializeCatalogCombo(); - this.initializeSchemaCombo(); - this.initializeTableCombo(); - - return composite; - } - - @Override - protected Control createContents(Composite parent) { - Composite composite = (Composite) super.createContents(parent); - - this.tableCombo.addModifyListener(buildTableModifyListener()); - this.catalogCombo.addSelectionListener(this.buildCatalogSelectionListener()); - this.schemaCombo.addSelectionListener(this.buildSchemaSelectionListener()); - this.refreshButtons(); - return composite; - } - - protected void initializeCatalogCombo() { - this.populateCatalogCombo(); - - if (this.isAddDialog()) { - this.catalogCombo.select(0); // out-of-bounds index is ignored - } else { - String specifiedCatalog = this.secondaryTable.getSpecifiedCatalog(); - if (specifiedCatalog == null) { - this.catalogCombo.select(0); // out-of-bounds index is ignored - } else { - this.catalogCombo.setText(specifiedCatalog); - } - } - } - - protected void populateCatalogCombo() { - Database database = this.getDatabase(); - if ((database != null) && ! database.supportsCatalogs()) { - this.catalogCombo.setEnabled(false); - return; - } - - // add the default catalog first - if (this.defaultCatalog != null) { - this.catalogCombo.add(NLS.bind(JptUiDetailsMessages.SecondaryTableDialog_defaultCatalog, this.defaultCatalog)); - } - - if (database != null) { - for (String identifier : database.getSortedCatalogIdentifiers()) { - this.catalogCombo.add(identifier); - } - } - } - - protected void initializeSchemaCombo() { - this.populateSchemaCombo(); - - if (this.isAddDialog()) { - this.schemaCombo.select(0); // out-of-bounds index is ignored - } else { - String specifiedSchema = this.secondaryTable.getSpecifiedSchema(); - if (specifiedSchema == null) { - this.schemaCombo.select(0); // out-of-bounds index is ignored - } else { - this.schemaCombo.setText(specifiedSchema); - } - } - } - - // assume the catalog combo has been populated by now - protected void populateSchemaCombo() { - // add the default schema first - if (this.defaultSchema != null) { - this.schemaCombo.add(NLS.bind(JptUiDetailsMessages.SecondaryTableDialog_defaultSchema, this.defaultSchema)); - } - - SchemaContainer sc = this.getCurrentDbSchemaContainer(); - if (sc != null) { - for (String identifier : sc.getSortedSchemaIdentifiers()) { - this.schemaCombo.add(identifier); - } - } - } - - protected void initializeTableCombo() { - this.populateTableCombo(); - - if (this.isEditDialog()) { - String specifiedName = this.secondaryTable.getSpecifiedName(); - if (specifiedName != null) { - this.tableCombo.setText(specifiedName); - } - } - } - - // assume the schema combo has been populated by now - protected void populateTableCombo() { - // we don't need to add a "default" to the table combo - Schema dbSchema = this.getCurrentDbSchema(); - if (dbSchema != null) { - for (String identifier : dbSchema.getSortedTableIdentifiers()) { - this.tableCombo.add(identifier); - } - } - } - - - // ********** listeners ********** - - protected SelectionListener buildCatalogSelectionListener() { - return new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - SecondaryTableDialog.this.selectedCatalogChanged(); - } - public void widgetDefaultSelected(SelectionEvent e) { - SecondaryTableDialog.this.selectedCatalogChanged(); - } - @Override - public String toString() { - return "catalog selection listener"; //$NON-NLS-1$ - } - }; - } - - protected void selectedCatalogChanged() { - this.refreshSchemaCombo(); - this.refreshTableCombo(); - } - - protected void refreshSchemaCombo() { - String schema = this.schemaCombo.getText(); - this.schemaCombo.removeAll(); - this.populateSchemaCombo(); - this.schemaCombo.setText(schema); - } - - protected SelectionListener buildSchemaSelectionListener() { - return new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - SecondaryTableDialog.this.selectedSchemaChanged(); - } - public void widgetDefaultSelected(SelectionEvent e) { - SecondaryTableDialog.this.selectedSchemaChanged(); - } - @Override - public String toString() { - return "schema selection listener"; //$NON-NLS-1$ - } - }; - } - - protected void selectedSchemaChanged() { - this.refreshTableCombo(); - } - - protected void refreshTableCombo() { - String table = this.tableCombo.getText(); - this.tableCombo.removeAll(); - this.populateTableCombo(); - this.tableCombo.setText(table); - } - - protected ModifyListener buildTableModifyListener() { - return new ModifyListener() { - public void modifyText(ModifyEvent event) { - SecondaryTableDialog.this.tableChanged(); - } - @Override - public String toString() { - return "table modify listener"; //$NON-NLS-1$ - } - }; - } - - protected void tableChanged() { - this.refreshButtons(); - } - - // ********** convenience methods ********** - - protected boolean isAddDialog() { - return this.secondaryTable == null; - } - - protected boolean isEditDialog() { - return ! this.isAddDialog(); - } - - protected Database getDatabase() { - return this.jpaProject.getDataSource().getDatabase(); - } - - protected SchemaContainer getCurrentDbSchemaContainer() { - Database database = this.getDatabase(); - if (database == null) { - return null; - } - if ( ! database.supportsCatalogs()) { - return database; - } - String catalog = this.getCurrentCatalog(); - return (catalog == null) ? null : database.getCatalogForIdentifier(catalog); - } - - protected String getCurrentCatalog() { - if ((this.defaultCatalog != null) && (this.catalogCombo.getSelectionIndex() == 0)) { - return this.defaultCatalog; - } - return convertText(this.catalogCombo); - } - - protected Schema getCurrentDbSchema() { - String schema = this.getCurrentSchema(); - if (schema == null) { - return null; - } - SchemaContainer sc = this.getCurrentDbSchemaContainer(); - return (sc == null) ? null : sc.getSchemaForIdentifier(schema); - } - - protected String getCurrentSchema() { - if ((this.defaultSchema != null) && (this.schemaCombo.getSelectionIndex() == 0)) { - return this.defaultSchema; - } - return convertText(this.schemaCombo); - } - - protected void refreshButtons() { - this.getButton(IDialogConstants.OK_ID).setEnabled(this.validateEntryValues()); - } - - protected boolean validateEntryValues() { - return ! StringTools.stringIsEmpty(this.tableCombo.getText()); - } - - - // ********** close ********** - - /** - * set all the various values queried by clients once the dialog is closed - */ - @Override - public boolean close() { - this.selectedTable = this.tableCombo.getText(); - this.selectedCatalog = convertText(this.catalogCombo, this.defaultCatalog); - this.selectedSchema = convertText(this.schemaCombo, this.defaultSchema); - return super.close(); - } - - /** - * return null if: - * - the default value is selected - * - the combo's text is empty - */ - protected static String convertText(Combo combo, String defaultText) { - // if the default text is present, then it will be the combo's first selection - if ((defaultText != null) && (combo.getSelectionIndex() == 0)) { - return null; - } - return convertText(combo); - } - - /** - * return null if the combo's text is empty - */ - protected static String convertText(Combo combo) { - String text = combo.getText(); - return (text.length() == 0) ? null : text; - } - - - // ********** public API ********** - - /** - * Return the selected table. Return an empty string if nothing - * is selected (since there is no default). - */ - public String getSelectedTable() { - return this.selectedTable; - } - - /** - * Return the selected catalog. Return null if either nothing or - * the default catalog is selected. - */ - public String getSelectedCatalog() { - return this.selectedCatalog; - } - - /** - * Return the selected schema. Return null if either nothing or - * the default schema is selected. - */ - public String getSelectedSchema() { - return this.selectedSchema; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/SequenceGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/SequenceGeneratorComposite.java deleted file mode 100644 index 585a418f98..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/SequenceGeneratorComposite.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.db.SequenceCombo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ----------------------------------------------------- | - * | Name: | I | | - * | ----------------------------------------------------- | - * | ----------------------------------------------------- | - * | Sequence Generator: | SequenceCombo | | - * | ----------------------------------------------------- | - * | ------------- | - * | Allocation Size: | I |I| | - * | ------------- | - * | ------------- | - * | Initial Value: | |I| | - * | ------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see IdMapping - * @see SequenceGenerator - * @see IdMappingGenerationComposite - The parent container - * @see SequenceCombo - * - * @version 2.2 - * @since 1.0 - */ -public class SequenceGeneratorComposite extends GeneratorComposite<SequenceGenerator> -{ - - public SequenceGeneratorComposite(Pane<?> parentPane, - PropertyValueModel<SequenceGenerator> subjectHolder, - Composite parent, - GeneratorBuilder<SequenceGenerator> builder) { - - super(parentPane, subjectHolder, parent, builder); - } - - @Override - protected String getPropertyName() { - return GeneratorContainer.SEQUENCE_GENERATOR_PROPERTY; - } - - @Override - protected void initializeLayout(Composite container) { - - // Name widgets - addLabeledText( - container, - JptUiDetailsMessages.SequenceGeneratorComposite_name, - buildGeneratorNameHolder(), - JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_NAME - ); - - // Sequence Generator widgets - addLabeledComposite( - container, - JptUiDetailsMessages.SequenceGeneratorComposite_sequence, - buildSequenceNameCombo(container), - JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_SEQUENCE - ); - - addAllocationSizeCombo(container); - addInitialValueCombo(container); - } - - protected SequenceCombo<SequenceGenerator> buildSequenceNameCombo(Composite parent) { - - return new SequenceCombo<SequenceGenerator>(this, getSubjectHolder(), parent) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(SequenceGenerator.DEFAULT_SEQUENCE_NAME_PROPERTY); - propertyNames.add(SequenceGenerator.SPECIFIED_SEQUENCE_NAME_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultSequenceName(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedSequenceName(value); - } - - @Override - protected String getValue() { - return (getSubject() == null) ? null : getSubject().getSpecifiedSequenceName(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return SequenceGeneratorComposite.this.getJpaProject(); - } - - @Override - protected Schema getDbSchema_() { - return this.getSubject().getDbSchema(); - } - - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TableComposite.java deleted file mode 100644 index 7c3ada7fe6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TableComposite.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.Table; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.TableCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - Table ----------------------------------------------------------------- | - * | | ------------------------------------------------------------ | | - * | | Table: | TableCombo | | | - * | | ------------------------------------------------------------ | | - * | | ------------------------------------------------------------ | | - * | | Catalog: | CatalogCombo | | | - * | | ------------------------------------------------------------ | | - * | | ------------------------------------------------------------ | | - * | | Schema: | SchemaCombo | | | - * | | ------------------------------------------------------------ | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Table - * @see EntityComposite - The parent container - * @see TableCombo - * @see CatalogCombo - * @see SchemaCombo - * - * @TODO repopulate this panel based on the Entity table changing - * - * @version 2.0 - * @since 1.0 - */ -public class TableComposite extends Pane<Entity> -{ - /** - * Creates a new <code>TableComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of the subject - * @param parent The parent container - */ - public TableComposite(Pane<? extends Entity> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - @Override - protected void initializeLayout(Composite container) { - - // Table group pane - Group tableGroupPane = addTitledGroup( - container, - JptUiDetailsMessages.TableComposite_tableSection - ); - - PropertyValueModel<Table> subjectHolder = buildTableHolder(); - // Table widgets - addLabeledComposite( - tableGroupPane, - JptUiDetailsMessages.TableChooser_label, - addTableCombo(subjectHolder, tableGroupPane), - JpaHelpContextIds.ENTITY_TABLE - ); - - // Catalog widgets - addLabeledComposite( - tableGroupPane, - JptUiDetailsMessages.CatalogChooser_label, - addCatalogCombo(subjectHolder, tableGroupPane), - JpaHelpContextIds.ENTITY_CATALOG - ); - - // Schema widgets - addLabeledComposite( - tableGroupPane, - JptUiDetailsMessages.SchemaChooser_label, - addSchemaCombo(subjectHolder, tableGroupPane), - JpaHelpContextIds.ENTITY_SCHEMA - ); - - new PaneEnabler(buildTableEnabledHolder(), this); - } - - protected WritablePropertyValueModel<Table> buildTableHolder() { - - return new PropertyAspectAdapter<Entity, Table>(getSubjectHolder(), Entity.TABLE_IS_UNDEFINED_PROPERTY) { - @Override - protected Table buildValue_() { - return this.subject.tableIsUndefined() ? null : this.subject.getTable(); - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildTableEnabledHolder() { - return new PropertyAspectAdapter<Entity, Boolean>(getSubjectHolder(), Entity.SPECIFIED_TABLE_IS_ALLOWED_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.specifiedTableIsAllowed()); - } - }; - } - - private CatalogCombo<Table> addCatalogCombo(PropertyValueModel<Table> tableHolder, Composite container) { - - return new CatalogCombo<Table>(this, tableHolder, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(Table.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(Table.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultCatalog(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedCatalog(); - } - }; - } - - private SchemaCombo<Table> addSchemaCombo(PropertyValueModel<Table> subjectHolder, Composite container) { - - return new SchemaCombo<Table>(this, subjectHolder, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(Table.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(Table.SPECIFIED_SCHEMA_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultSchema(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - return this.getSubject().getDbSchemaContainer(); - } - }; - } - - private TableCombo<Table> addTableCombo(PropertyValueModel<Table> subjectHolder, Composite container) { - - return new TableCombo<Table>(this, subjectHolder, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(Table.DEFAULT_NAME_PROPERTY); - propertyNames.add(Table.SPECIFIED_NAME_PROPERTY); - propertyNames.add(Table.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(Table.SPECIFIED_SCHEMA_PROPERTY); - propertyNames.add(Table.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(Table.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - if (propertyName == Table.DEFAULT_SCHEMA_PROPERTY - || propertyName == Table.SPECIFIED_SCHEMA_PROPERTY - || propertyName == Table.DEFAULT_CATALOG_PROPERTY - || propertyName == Table.SPECIFIED_CATALOG_PROPERTY ) { - repopulate(); - } - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultName(); - } - - @Override - protected void setValue(String value) { - this.getSubject().setSpecifiedName(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedName(); - } - - @Override - protected Schema getDbSchema_() { - return this.getSubject().getDbSchema(); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TableGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TableGeneratorComposite.java deleted file mode 100644 index 3cc2853ef4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TableGeneratorComposite.java +++ /dev/null @@ -1,499 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.TableGenerator; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.ColumnCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.TableCombo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ----------------------------------------------- | - * | Name: | I | | - * | ----------------------------------------------- | - * | ----------------------------------------------- | - * | Table: | TableCombo | | - * | ----------------------------------------------- | - * | ----------------------------------------------- | - * | Catalog: | CatalogCombo | | - * | ----------------------------------------------- | - * | ----------------------------------------------- | - * | Schema: | SchemaCombo | | - * | ----------------------------------------------- | - * | ----------------------------------------------- | - * | Primary Key Column: | ColumnCombo | | - * | ----------------------------------------------- | - * | ----------------------------------------------- | - * | Value Column: | ColumnCombo | | - * | ----------------------------------------------- | - * | ----------------------------------------------- | - * | Primary Key Column Value: | ColumnCombo | | - * | ----------------------------------------------- | - * | ------------- | - * | Allocation Size: | I |I| Default (XX) | - * | ------------- | - * | ------------- | - * | Initial Value: | I |I| Default (XX) | - * | ------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see IdMapping - * @see TableGenerator - * @see IdMappingGenerationComposite - The parent container - * @see CatalogCombo - * @see ColumnCombo - * @see SchemaCombo - * @see TableCombo - * - * @version 2.2 - * @since 1.0 - */ -public class TableGeneratorComposite extends GeneratorComposite<TableGenerator> -{ - - - public TableGeneratorComposite(Pane<?> parentPane, - PropertyValueModel<TableGenerator> subjectHolder, - Composite parent, - GeneratorBuilder<TableGenerator> builder) { - - super(parentPane, subjectHolder, parent, builder); - } - - @Override - protected String getPropertyName() { - return GeneratorContainer.TABLE_GENERATOR_PROPERTY; - } - - - @Override - protected void initializeLayout(Composite container) { - - // Name widgets - addLabeledText( - container, - JptUiDetailsMessages.TableGeneratorComposite_name, - buildGeneratorNameHolder(), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_NAME - ); - - // Table widgets - addLabeledComposite( - container, - JptUiDetailsMessages.TableGeneratorComposite_table, - addTableNameCombo(container), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_TABLE - ); - - // Schema widgets - addLabeledComposite( - container, - JptUiDetailsMessages.TableGeneratorComposite_schema, - addSchemaCombo(container), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_SCHEMA - ); - - // Catalog widgets - addLabeledComposite( - container, - JptUiDetailsMessages.TableGeneratorComposite_catalog, - addCatalogCombo(container), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_CATALOG - ); - - // Primary Key Column widgets - addLabeledComposite( - container, - JptUiDetailsMessages.TableGeneratorComposite_pkColumn, - addPkColumnNameCombo(container), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN - ); - - // Value Column widgets - addLabeledComposite( - container, - JptUiDetailsMessages.TableGeneratorComposite_valueColumn, - addValueColumnCombo(container), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_VALUE_COLUMN - ); - - // Primary Key Column Value widgets - addLabeledComposite( - container, - JptUiDetailsMessages.TableGeneratorComposite_pkColumnValue, - addPkColumnValueCombo(container), - JpaHelpContextIds.MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN_VALUE - ); - - addAllocationSizeCombo(container); - addInitialValueCombo(container); - } - - private CatalogCombo<TableGenerator> addCatalogCombo(Composite container) { - - return new CatalogCombo<TableGenerator>(this, getSubjectHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(TableGenerator.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultCatalog(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return TableGeneratorComposite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedCatalog(); - } - }; - } - - private ColumnCombo<TableGenerator> addPkColumnNameCombo(Composite parent) { - - return new ColumnCombo<TableGenerator>(this, getSubjectHolder(), parent) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(TableGenerator.DEFAULT_PK_COLUMN_NAME_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_PK_COLUMN_NAME_PROPERTY); - propertyNames.add(TableGenerator.DEFAULT_TABLE_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_TABLE_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == TableGenerator.DEFAULT_TABLE_PROPERTY || - propertyName == TableGenerator.SPECIFIED_TABLE_PROPERTY) { - this.repopulateComboBox(); - } else { - super.propertyChanged(propertyName); - } - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultPkColumnName(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return TableGeneratorComposite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedPkColumnName(value); - } - - @Override - protected Table getDbTable_() { - return getSubject().getDbTable(); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedPkColumnName(); - } - }; - } - - private ColumnCombo<TableGenerator> addPkColumnValueCombo(Composite parent) { - - return new ColumnCombo<TableGenerator>(this, getSubjectHolder(), parent) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(TableGenerator.DEFAULT_PK_COLUMN_VALUE_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_PK_COLUMN_VALUE_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultPkColumnValue(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return TableGeneratorComposite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedPkColumnValue(value); - } - - @Override - protected Table getDbTable_() { - return getSubject().getDbTable(); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedPkColumnValue(); - } - }; - } - - private SchemaCombo<TableGenerator> addSchemaCombo(Composite container) { - - return new SchemaCombo<TableGenerator>(this, getSubjectHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(TableGenerator.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_SCHEMA_PROPERTY); - propertyNames.add(TableGenerator.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == TableGenerator.DEFAULT_CATALOG_PROPERTY - || propertyName == TableGenerator.SPECIFIED_CATALOG_PROPERTY ) { - repopulateComboBox(); - } - else { - super.propertyChanged(propertyName); - } - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultSchema(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return TableGeneratorComposite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer() { - TableGenerator tg = this.getSubject(); - if (tg != null) { - return tg.getDbSchemaContainer(); - } - return TableGeneratorComposite.this.getSubject().getContextDefaultDbSchemaContainer(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - // we overrode #getDbSchemaContainer() instead - throw new UnsupportedOperationException(); - } - }; - } - - private TableCombo<TableGenerator> addTableNameCombo(Composite parent) { - - return new TableCombo<TableGenerator>(this, getSubjectHolder(), parent) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(TableGenerator.DEFAULT_TABLE_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_TABLE_PROPERTY); - propertyNames.add(TableGenerator.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_SCHEMA_PROPERTY); - propertyNames.add(TableGenerator.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == TableGenerator.DEFAULT_SCHEMA_PROPERTY - || propertyName == TableGenerator.SPECIFIED_SCHEMA_PROPERTY - || propertyName == TableGenerator.DEFAULT_CATALOG_PROPERTY - || propertyName == TableGenerator.SPECIFIED_CATALOG_PROPERTY ) { - repopulateComboBox(); - } - else { - super.propertyChanged(propertyName); - } - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultTable(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return TableGeneratorComposite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedTable(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedTable(); - } - - @Override - protected Schema getDbSchema() { - TableGenerator tg = this.getSubject(); - if (tg != null) { - return tg.getDbSchema(); - } - return TableGeneratorComposite.this.getSubject().getContextDefaultDbSchema(); - } - - @Override - protected Schema getDbSchema_() { - // we overrode #getDbSchema() instead - throw new UnsupportedOperationException(); - } - - }; - } - - private ColumnCombo<TableGenerator> addValueColumnCombo(Composite parent) { - - return new ColumnCombo<TableGenerator>(this, getSubjectHolder(), parent) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(TableGenerator.DEFAULT_VALUE_COLUMN_NAME_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_VALUE_COLUMN_NAME_PROPERTY); - propertyNames.add(TableGenerator.DEFAULT_TABLE_PROPERTY); - propertyNames.add(TableGenerator.SPECIFIED_TABLE_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == TableGenerator.DEFAULT_TABLE_PROPERTY || - propertyName == TableGenerator.SPECIFIED_TABLE_PROPERTY) { - this.repopulateComboBox(); - } else { - super.propertyChanged(propertyName); - } - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultValueColumnName(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return TableGeneratorComposite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - retrieveGenerator().setSpecifiedValueColumnName(value); - } - - @Override - protected Table getDbTable_() { - return getSubject().getDbTable(); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedValueColumnName(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityComposite.java deleted file mode 100644 index 20e4b4ad09..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TargetEntityComposite.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2006, 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 -*******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserComboPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * target entity hyperlink label, combo and browse button - */ -public class TargetEntityComposite - extends ClassChooserComboPane<RelationshipMapping> -{ - /** - * Creates a new <code>TargetEntityComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public TargetEntityComposite( - Pane<? extends RelationshipMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected String getClassName() { - return getSubject().getTargetEntity(); - } - - @Override - protected void setClassName(String className) { - this.getSubject().setSpecifiedTargetEntity(className); - } - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.TargetEntityChooser_label; - } - - @Override - protected String getHelpId() { - return JpaHelpContextIds.MAPPING_TARGET_ENTITY; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected char getEnclosingTypeSeparator() { - return getSubject().getTargetEntityEnclosingTypeSeparator(); - } - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<RelationshipMapping, String>(this.getSubjectHolder(), RelationshipMapping.SPECIFIED_TARGET_ENTITY_PROPERTY) { - @Override - protected String buildValue_() { - - String name = this.subject.getSpecifiedTargetEntity(); - if (name == null) { - name = TargetEntityComposite.this.getDefaultValue(this.subject); - } - return name; - } - - @Override - protected void setValue_(String value) { - - if (getDefaultValue(this.subject).equals(value)) { - value = null; - } - this.subject.setSpecifiedTargetEntity(value); - } - }; - } - - @Override - protected ListValueModel<String> buildClassListHolder() { - return this.buildDefaultProfilerListHolder(); - } - - private ListValueModel<String> buildDefaultProfilerListHolder() { - return new PropertyListValueModelAdapter<String>( - this.buildDefaultProfilerHolder() - ); - } - - private PropertyValueModel<String> buildDefaultProfilerHolder() { - return new PropertyAspectAdapter<RelationshipMapping, String>(this.getSubjectHolder(), RelationshipMapping.DEFAULT_TARGET_ENTITY_PROPERTY) { - @Override - protected String buildValue_() { - return TargetEntityComposite.this.getDefaultValue(this.subject); - } - }; - } - - private String getDefaultValue(RelationshipMapping subject) { - String defaultValue = subject.getDefaultTargetEntity(); - - if (defaultValue != null) { - return NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - defaultValue - ); - } - return JptCommonUiMessages.DefaultEmpty; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TemporalTypeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TemporalTypeComposite.java deleted file mode 100644 index 65c6d2fc46..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TemporalTypeComposite.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details; - -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.TemporalConverter; -import org.eclipse.jpt.jpa.core.context.TemporalType; -import org.eclipse.swt.widgets.Composite; - -import com.ibm.icu.text.Collator; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | --------------------------------------------------------------- | - * | Temporal: | |v| | - * | --------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see ColumnMapping - * @see TemporalType - * @see BasicMappingComposite - A container of this pane - * @see IdMappingComposite - A container of this pane - * @see VersionMappingComposite - A container of this pane - * - * @version 2.0 - * @since 1.0 - */ -public class TemporalTypeComposite extends Pane<TemporalConverter> { - - /** - * Creates a new <code>TemporalTypeComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public TemporalTypeComposite(PropertyValueModel<? extends TemporalConverter> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - this.addCombo( - container, - buildTemporalTypeListHolder(), - buildTemporalTypeHolder(), - buildTemporalTypeConverter(), - buildBooleanHolder() - ); - } - - private WritablePropertyValueModel<TemporalType> buildTemporalTypeHolder() { - return new PropertyAspectAdapter<TemporalConverter, TemporalType>(getSubjectHolder(), TemporalConverter.TEMPORAL_TYPE_PROPERTY) { - @Override - protected TemporalType buildValue_() { - return subject.getTemporalType(); - } - - @Override - protected void setValue_(TemporalType value) { - subject.setTemporalType(value); - } - }; - } - - private ListValueModel<TemporalType> buildTemporalTypeListHolder() { - return new SimpleListValueModel<TemporalType>( - buildSortedTemporalTypeList() - ); - } - - private List<TemporalType> buildSortedTemporalTypeList() { - return CollectionTools.sort(CollectionTools.list(TemporalType.values()), this.buildTemporalTypeComparator()); - } - - private Comparator<TemporalType> buildTemporalTypeComparator() { - return new Comparator<TemporalType>() { - public int compare(TemporalType type1, TemporalType type2) { - String displayString1 = displayString(type1); - String displayString2 = displayString(type2); - return Collator.getInstance().compare(displayString1, displayString2); - } - }; - } - - private StringConverter<TemporalType> buildTemporalTypeConverter() { - return new StringConverter<TemporalType>() { - public String convertToString(TemporalType value) { - return (value == null) ? null : displayString(value); - } - }; - } - - String displayString(TemporalType temporalType) { - return SWTUtil.buildDisplayString( - JptUiDetailsMessages.class, - TemporalTypeComposite.this, - temporalType.name() - ); - } - - protected PropertyValueModel<Boolean> buildBooleanHolder() { - return new TransformationPropertyValueModel<TemporalConverter, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(TemporalConverter value) { - if (getSubject() != null && getSubject().getParent().getPersistentAttribute().isVirtual()) { - return Boolean.FALSE; - } - return Boolean.valueOf(value != null); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TransientMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TransientMappingComposite.java deleted file mode 100644 index f6768f3d1f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/TransientMappingComposite.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.TransientMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * This pane does not have any widgets. - * - * @see TransientMapping - * - * @version 2.0 - * @since 1.0 - */ -public class TransientMappingComposite extends Pane<TransientMapping> - implements JpaComposite -{ - /** - * Creates a new <code>TransientMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>ITransientMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public TransientMappingComposite(PropertyValueModel<? extends TransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/VersionMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/VersionMappingComposite.java deleted file mode 100644 index 1d5c4a60b4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/VersionMappingComposite.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.VersionMapping; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see VersionMapping - * @see ColumnComposite - * @see TemporalTypeComposite - * - * @version 2.3 - * @since 1.0 - */ -public class VersionMappingComposite - extends AbstractVersionMappingComposite<VersionMapping> -{ - /** - * Creates a new <code>VersionMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IVersionMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public VersionMappingComposite(PropertyValueModel<? extends VersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeVersionSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/CatalogCombo.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/CatalogCombo.java deleted file mode 100644 index dff170cb8f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/CatalogCombo.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.db; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.swt.widgets.Composite; - -/** - * This combo-box displays the database's catalogs. - */ -public abstract class CatalogCombo<T extends JpaNode> - extends DatabaseObjectCombo<T> -{ - public CatalogCombo( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - public CatalogCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected Iterable<String> getValues_() { - return this.getDatabase().getSortedCatalogIdentifiers(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/ColumnCombo.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/ColumnCombo.java deleted file mode 100644 index 99243ac41a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/ColumnCombo.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.db; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.swt.widgets.Composite; - -/** - * This combo-box displays a table's columns. - */ -public abstract class ColumnCombo<T extends JpaNode> - extends DatabaseObjectCombo<T> -{ - public ColumnCombo( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - public ColumnCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected Iterable<String> getValues_() { - Table dbTable = this.getDbTable(); - return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String>instance(); - } - - protected Table getDbTable() { - return (this.getSubject() == null) ? null : this.getDbTable_(); - } - - /** - * Assume the subject is not null. - */ - protected abstract Table getDbTable_(); - - @Override - protected void tableChanged_(Table table) { - super.tableChanged_(table); - if (this.getDbTable() == table) { - this.doPopulate(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/DatabaseObjectCombo.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/DatabaseObjectCombo.java deleted file mode 100644 index 1a670e1ee3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/DatabaseObjectCombo.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.db; - -import org.eclipse.jpt.common.ui.internal.Tracing; -import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper; -import org.eclipse.jpt.common.ui.internal.widgets.ComboPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -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.jpa.core.JpaDataSource; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.db.Catalog; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.ConnectionListener; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.ForeignKey; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Sequence; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.ui.internal.listeners.SWTConnectionListenerWrapper; -import org.eclipse.swt.widgets.Composite; - -/** - * This abstract pane keeps a combo in sync with the database objects - * when a connection is active. - * - * @see CatalogCombo - * @see ColumnCombo - * @see SchemaCombo - * @see SequenceCombo - * @see TableCombo - */ -@SuppressWarnings("nls") -public abstract class DatabaseObjectCombo<T extends JpaNode> - extends ComboPane<T> -{ - /** - * The listener added to the <code>ConnectionProfile</code>. - * It keeps the combo in sync with the database metadata. - */ - private ConnectionListener connectionListener; - - private PropertyChangeListener connectionProfileListener; - - - // ********** constructors ********** - - protected DatabaseObjectCombo( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - protected DatabaseObjectCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - // ********** initialization ********** - - @Override - protected void initialize() { - super.initialize(); - this.connectionListener = this.buildConnectionListener(); - this.connectionProfileListener = this.buildConnectionProfileListener(); - } - - protected ConnectionListener buildConnectionListener() { - return new SWTConnectionListenerWrapper(this.buildConnectionListener_()); - } - - protected ConnectionListener buildConnectionListener_() { - return new LocalConnectionListener(); - } - - protected PropertyChangeListener buildConnectionProfileListener() { - return new SWTPropertyChangeListenerWrapper(this.buildConnectionProfileListener_()); - } - - protected PropertyChangeListener buildConnectionProfileListener_() { - return new PropertyChangeListener(){ - - public void propertyChanged(PropertyChangeEvent event) { - connectionProfileChanged(event); - } - }; - } - - protected void connectionProfileChanged(PropertyChangeEvent event) { - if (event.getOldValue() != null) { - ((ConnectionProfile) event.getOldValue()).removeConnectionListener(this.connectionListener); - } - if (event.getNewValue() != null) { - ((ConnectionProfile) event.getNewValue()).addConnectionListener(this.connectionListener); - } - this.repopulateComboBox(); - } - - - // ********** overrides ********** - - @Override - protected void engageListeners_(T subject) { - super.engageListeners_(subject); - - subject.getJpaProject().getDataSource().addPropertyChangeListener(JpaDataSource.CONNECTION_PROFILE_PROPERTY, this.connectionProfileListener); - ConnectionProfile cp = subject.getJpaProject().getConnectionProfile(); - if (cp != null) { - cp.addConnectionListener(this.connectionListener); - } - } - - @Override - protected void disengageListeners_(T subject) { - ConnectionProfile cp = subject.getJpaProject().getConnectionProfile(); - if (cp != null) { - cp.removeConnectionListener(this.connectionListener); - } - subject.getJpaProject().getDataSource().removePropertyChangeListener(JpaDataSource.CONNECTION_PROFILE_PROPERTY, this.connectionProfileListener); - - super.disengageListeners_(subject); - } - - @Override - protected final Iterable<String> getValues() { - return this.connectionProfileIsActive() ? this.getValues_() : EmptyIterable.<String>instance(); - } - - /** - * Called only when connection profile is active - */ - protected abstract Iterable<String> getValues_(); - - - // ********** convenience methods ********** - - /** - * Return the subject's JPA project. - * Allow subclasses to override this method, so we can still get the JPA - * project even when the subject is null. - */ - protected JpaProject getJpaProject() { - T subject = this.getSubject(); - return (subject == null) ? null : subject.getJpaProject(); - } - - /** - * Return the subject's connection profile. - */ - protected final ConnectionProfile getConnectionProfile() { - JpaProject jpaProject = this.getJpaProject(); - return (jpaProject == null) ? null : jpaProject.getConnectionProfile(); - } - - /** - * Return whether the subject's connection profile is active. - */ - protected final boolean connectionProfileIsActive() { - ConnectionProfile cp = this.getConnectionProfile(); - return (cp != null) && cp.isActive(); - } - - /** - * Returns the subject's database. - */ - protected final Database getDatabase() { - ConnectionProfile cp = this.getConnectionProfile(); - return (cp == null) ? null : cp.getDatabase(); - } - - - // ********** connection listener callbacks ********** - - protected final void databaseChanged(Database database) { - if ( ! this.comboBox.isDisposed()) { - this.databaseChanged_(database); - } - } - - protected void databaseChanged_(@SuppressWarnings("unused") Database database) { - // do nothing by default - } - - protected final void catalogChanged(Catalog catalog) { - if ( ! this.comboBox.isDisposed()) { - this.catalogChanged_(catalog); - } - } - - protected void catalogChanged_(@SuppressWarnings("unused") Catalog catalog) { - // do nothing by default - } - - protected final void schemaChanged(Schema schema) { - if ( ! this.comboBox.isDisposed()) { - this.schemaChanged_(schema); - } - } - - protected void schemaChanged_(@SuppressWarnings("unused") Schema schema) { - // do nothing by default - } - - protected final void sequenceChanged(Sequence sequence) { - if ( ! this.comboBox.isDisposed()) { - this.sequenceChanged_(sequence); - } - } - - protected void sequenceChanged_(@SuppressWarnings("unused") Sequence sequence) { - // do nothing by default - } - - protected final void tableChanged(Table table) { - if ( ! this.comboBox.isDisposed()) { - this.tableChanged_(table); - } - } - - protected void tableChanged_(@SuppressWarnings("unused") Table table) { - // do nothing by default - } - - protected final void columnChanged(Column column) { - if ( ! this.comboBox.isDisposed()) { - this.columnChanged_(column); - } - } - - protected void columnChanged_(@SuppressWarnings("unused") Column column) { - // do nothing by default - } - - protected final void foreignKeyChanged(ForeignKey foreignKey) { - if ( ! this.comboBox.isDisposed()) { - this.foreignKeyChanged_(foreignKey); - } - } - - protected void foreignKeyChanged_(@SuppressWarnings("unused") ForeignKey foreignKey) { - // do nothing by default - } - - @Override - protected void log(String flag, String message) { - if (flag.equals(Tracing.UI_DB) && Tracing.booleanDebugOption(Tracing.UI_DB)) { - this.log(message); - } else { - super.log(flag, message); - } - } - - // broaden accessibility a bit - @Override - protected void repopulateComboBox() { - super.repopulateComboBox(); - } - - - // ********** connection listener ********** - - protected class LocalConnectionListener - implements ConnectionListener - { - protected LocalConnectionListener() { - super(); - } - - public void opened(ConnectionProfile profile) { - this.log("opened: " + profile.getName()); - DatabaseObjectCombo.this.repopulateComboBox(); - } - - public void modified(ConnectionProfile profile) { - this.log("modified: " + profile.getName()); - DatabaseObjectCombo.this.repopulateComboBox(); - } - - public boolean okToClose(ConnectionProfile profile) { - this.log("OK to close: " + profile.getName()); - return true; - } - - public void aboutToClose(ConnectionProfile profile) { - this.log("about to close: " + profile.getName()); - } - - public void closed(ConnectionProfile profile) { - this.log("closed: " + profile.getName()); - DatabaseObjectCombo.this.repopulateComboBox(); - } - - public void databaseChanged(ConnectionProfile profile, Database database) { - this.log("database changed: " + database.getName()); - DatabaseObjectCombo.this.databaseChanged(database); - } - - public void catalogChanged(ConnectionProfile profile, Catalog catalog) { - this.log("catalog changed: " + catalog.getName()); - DatabaseObjectCombo.this.catalogChanged(catalog); - } - - public void schemaChanged(ConnectionProfile profile, Schema schema) { - this.log("schema changed: " + schema.getName()); - DatabaseObjectCombo.this.schemaChanged(schema); - } - - public void sequenceChanged(ConnectionProfile profile, Sequence sequence) { - this.log("sequence changed: " + sequence.getName()); - DatabaseObjectCombo.this.sequenceChanged(sequence); - } - - public void tableChanged(ConnectionProfile profile, Table table) { - this.log("table changed: " + table.getName()); - DatabaseObjectCombo.this.tableChanged(table); - } - - public void columnChanged(ConnectionProfile profile, Column column) { - this.log("column changed: " + column.getName()); - DatabaseObjectCombo.this.columnChanged(column); - } - - public void foreignKeyChanged(ConnectionProfile profile, ForeignKey foreignKey) { - this.log("foreign key changed: " + foreignKey.getName()); - DatabaseObjectCombo.this.foreignKeyChanged(foreignKey); - } - - protected void log(String message) { - DatabaseObjectCombo.this.log(Tracing.UI_DB, message); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/SchemaCombo.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/SchemaCombo.java deleted file mode 100644 index cf3605efe6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/SchemaCombo.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.db; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.swt.widgets.Composite; - -/** - * This combo-box displays a schema container's schemata. - */ -public abstract class SchemaCombo<T extends JpaNode> - extends DatabaseObjectCombo<T> -{ - public SchemaCombo( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - public SchemaCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected Iterable<String> getValues_() { - SchemaContainer sc = this.getDbSchemaContainer(); - return (sc != null) ? sc.getSortedSchemaIdentifiers() : EmptyIterable.<String>instance(); - } - - protected SchemaContainer getDbSchemaContainer() { - return (this.getSubject() == null) ? null : this.getDbSchemaContainer_(); - } - - /** - * Assume the subject is not null. - */ - protected abstract SchemaContainer getDbSchemaContainer_(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/SequenceCombo.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/SequenceCombo.java deleted file mode 100644 index c54ec57d03..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/SequenceCombo.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.db; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.swt.widgets.Composite; - -/** - * This combo-box displays a schema's sequences. - */ -public abstract class SequenceCombo<T extends JpaNode> - extends DatabaseObjectCombo<T> -{ - public SequenceCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected Iterable<String> getValues_() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema != null) ? dbSchema.getSortedSequenceIdentifiers() : EmptyIterable.<String>instance(); - } - - protected Schema getDbSchema() { - return (this.getSubject() == null) ? null : this.getDbSchema_(); - } - - /** - * Assume the subject is not null. - */ - protected abstract Schema getDbSchema_(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/TableCombo.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/TableCombo.java deleted file mode 100644 index c347b77c82..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/db/TableCombo.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.db; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.swt.widgets.Composite; - -/** - * This combo-box displays a schema's tables. - */ -public abstract class TableCombo<T extends JpaNode> - extends DatabaseObjectCombo<T> -{ - public TableCombo( - Pane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - public TableCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected Iterable<String> getValues_() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String>instance(); - } - - protected Schema getDbSchema() { - return (this.getSubject() == null) ? null : this.getDbSchema_(); - } - - /** - * Assume the subject is not null. - */ - protected abstract Schema getDbSchema_(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java deleted file mode 100644 index 6fc1e31081..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.java; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.structure.JavaResourceModelStructureProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; -import org.eclipse.swt.widgets.Composite; - -/** - * All the state in the definition should be "static" (i.e. unchanging once it is initialized). - */ -public abstract class AbstractJavaResourceUiDefinition - implements MappingResourceUiDefinition -{ - private JavaTypeMappingUiDefinition<? extends TypeMapping>[] specifiedTypeMappingUiDefinitions; - - private JavaAttributeMappingUiDefinition<? extends AttributeMapping>[] specifiedAttributeMappingUiDefinitions; - - private DefaultJavaAttributeMappingUiDefinition<?>[] defaultAttributeMappingUiDefinitions; - - private final JavaUiFactory factory; - - - /** - * zero-argument constructor - */ - protected AbstractJavaResourceUiDefinition() { - super(); - this.factory = buildJavaUiFactory(); - } - - - protected abstract JavaUiFactory buildJavaUiFactory(); - - public JavaUiFactory getFactory() { - return this.factory; - } - - public boolean providesUi(JptResourceType resourceType) { - return resourceType.equals(JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE); - } - - public JpaStructureProvider getStructureProvider() { - return JavaResourceModelStructureProvider.instance(); - } - - - - // ********** type mapping ui definitions ********** - - public JpaComposite buildTypeMappingComposite( - String key, - PropertyValueModel<TypeMapping> mappingHolder, - Composite parent, - WidgetFactory widgetFactory) { - - JavaTypeMappingUiDefinition<TypeMapping> mappingUiDefinition = getJavaTypeMappingUiDefinition(mappingHolder.getValue()); - return mappingUiDefinition.buildTypeMappingComposite( - getFactory(), - mappingHolder, - parent, - widgetFactory); - } - - @SuppressWarnings("unchecked") - protected JavaTypeMappingUiDefinition<TypeMapping> getJavaTypeMappingUiDefinition(TypeMapping typeMapping) { - if (typeMapping == null || typeMapping.getKey() == null) { - return (JavaTypeMappingUiDefinition<TypeMapping>) getDefaultTypeMappingUiDefinition(); - } - return (JavaTypeMappingUiDefinition<TypeMapping>) getSpecifiedJavaTypeMappingUiDefinition(typeMapping.getKey()); - } - - protected JavaTypeMappingUiDefinition<? extends TypeMapping> getSpecifiedJavaTypeMappingUiDefinition(String mappingKey) { - for (JavaTypeMappingUiDefinition<? extends TypeMapping> definition : getSpecifiedTypeMappingUiDefinitions()) { - if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) { - return definition; - } - } - throw new IllegalArgumentException("Illegal type mapping key: " + mappingKey); //$NON-NLS-1$ - } - - public Iterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>> typeMappingUiDefinitions() { - return new ArrayIterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>>( - getSpecifiedTypeMappingUiDefinitions()); - } - - protected synchronized JavaTypeMappingUiDefinition<? extends TypeMapping>[] getSpecifiedTypeMappingUiDefinitions() { - if (this.specifiedTypeMappingUiDefinitions == null) { - this.specifiedTypeMappingUiDefinitions = buildSpecifiedTypeMappingUiDefinitions(); - } - return this.specifiedTypeMappingUiDefinitions; - } - - /** - * Return an array of mapping definitions to use for types in mapping files of this type. - * The order is unimportant. - */ - protected JavaTypeMappingUiDefinition<? extends TypeMapping>[] buildSpecifiedTypeMappingUiDefinitions() { - ArrayList<JavaTypeMappingUiDefinition<? extends TypeMapping>> definitions = - new ArrayList<JavaTypeMappingUiDefinition<? extends TypeMapping>>(); - addSpecifiedTypeMappingUiDefinitionsTo(definitions); - @SuppressWarnings("unchecked") - JavaTypeMappingUiDefinition<? extends TypeMapping>[] definitionArray = - definitions.toArray(new JavaTypeMappingUiDefinition[definitions.size()]); - return definitionArray; - } - - protected abstract void addSpecifiedTypeMappingUiDefinitionsTo( - List<JavaTypeMappingUiDefinition<? extends TypeMapping>> definitions); - - public DefaultJavaTypeMappingUiDefinition<? extends TypeMapping> getDefaultTypeMappingUiDefinition() { - return NullJavaTypeMappingUiDefinition.instance(); - } - - - // ********** attributes mapping UI definitions ********** - - public JpaComposite buildAttributeMappingComposite( - String key, - PropertyValueModel<AttributeMapping> mappingHolder, - Composite parent, - WidgetFactory widgetFactory) { - - JavaAttributeMappingUiDefinition<AttributeMapping> mappingUiDefinition = - getAttributeMappingUiDefinition(mappingHolder.getValue()); - return mappingUiDefinition.buildAttributeMappingComposite( - getFactory(), - mappingHolder, - parent, - widgetFactory); - } - - @SuppressWarnings("unchecked") - protected JavaAttributeMappingUiDefinition<AttributeMapping> getAttributeMappingUiDefinition(AttributeMapping attributeMapping) { - String key = attributeMapping == null ? null : attributeMapping.getKey(); - if (attributeMapping == null || attributeMapping.isDefault()) { - return (JavaAttributeMappingUiDefinition<AttributeMapping>) getDefaultAttributeMappingUiDefinition(key); - } - return (JavaAttributeMappingUiDefinition<AttributeMapping>) getSpecifiedAttributeMappingUiDefinition(key); - } - - protected JavaAttributeMappingUiDefinition<? extends AttributeMapping> getSpecifiedAttributeMappingUiDefinition(String mappingKey) { - for (JavaAttributeMappingUiDefinition<? extends AttributeMapping> definition : getSpecifiedAttributeMappingUiDefinitions()) { - if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) { - return definition; - } - } - throw new IllegalArgumentException("Illegal attribute mapping key: " + mappingKey); //$NON-NLS-1$ - } - - public ListIterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>> - attributeMappingUiDefinitions() { - - return new ArrayListIterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>>( - getSpecifiedAttributeMappingUiDefinitions()); - } - - protected synchronized JavaAttributeMappingUiDefinition<? extends AttributeMapping>[] getSpecifiedAttributeMappingUiDefinitions() { - if (this.specifiedAttributeMappingUiDefinitions == null) { - this.specifiedAttributeMappingUiDefinitions = buildSpecifiedAttributeMappingUiDefinitions(); - } - return this.specifiedAttributeMappingUiDefinitions; - } - - /** - * Return an array of mapping definitions to use for attributes in mapping files of this type. - * The order is unimportant. - */ - protected JavaAttributeMappingUiDefinition<? extends AttributeMapping>[] buildSpecifiedAttributeMappingUiDefinitions() { - ArrayList<JavaAttributeMappingUiDefinition<? extends AttributeMapping>> definitions = - new ArrayList<JavaAttributeMappingUiDefinition<? extends AttributeMapping>>(); - addSpecifiedAttributeMappingUiDefinitionsTo(definitions); - @SuppressWarnings("unchecked") - JavaAttributeMappingUiDefinition<? extends AttributeMapping>[] definitionArray = - definitions.toArray(new JavaAttributeMappingUiDefinition[definitions.size()]); - return definitionArray; - } - - protected abstract void addSpecifiedAttributeMappingUiDefinitionsTo( - List<JavaAttributeMappingUiDefinition<? extends AttributeMapping>> definitions); - - - // ********** default Java attribute mapping UI providers ********** - - public DefaultJavaAttributeMappingUiDefinition<? extends AttributeMapping> getDefaultAttributeMappingUiDefinition(String key) { - for (DefaultJavaAttributeMappingUiDefinition<? extends AttributeMapping> definition : getDefaultAttributeMappingUiDefinitions()) { - if (Tools.valuesAreEqual(definition.getDefaultKey(), key)) { - return definition; - } - } - throw new IllegalArgumentException("Illegal attribute mapping key: " + key); //$NON-NLS-1$ - } - - protected synchronized DefaultJavaAttributeMappingUiDefinition<? extends AttributeMapping>[] getDefaultAttributeMappingUiDefinitions() { - if (this.defaultAttributeMappingUiDefinitions == null) { - this.defaultAttributeMappingUiDefinitions = this.buildDefaultAttributeMappingUiDefinitions(); - } - return this.defaultAttributeMappingUiDefinitions; - } - - protected DefaultJavaAttributeMappingUiDefinition<?>[] buildDefaultAttributeMappingUiDefinitions() { - ArrayList<DefaultJavaAttributeMappingUiDefinition<?>> definitions = - new ArrayList<DefaultJavaAttributeMappingUiDefinition<?>>(); - addDefaultAttributeMappingUiDefinitionsTo(definitions); - DefaultJavaAttributeMappingUiDefinition<?>[] definitionArray = - definitions.toArray(new DefaultJavaAttributeMappingUiDefinition[definitions.size()]); - return definitionArray; - } - - protected abstract void addDefaultAttributeMappingUiDefinitionsTo( - List<DefaultJavaAttributeMappingUiDefinition<?>> definitions); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/BaseJavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/BaseJavaUiFactory.java deleted file mode 100644 index df7051717d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/BaseJavaUiFactory.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.BasicMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EmbeddedIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ManyToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ManyToOneMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OneToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OneToOneMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TransientMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.VersionMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEmbeddableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappedSuperclassComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.java.JavaEmbeddedMapping2_0Composite; -import org.eclipse.swt.widgets.Composite; - -/** - * The default implementation of the UI factory required to show the information - * related to a JPA mapping (type or attribute). - */ -public abstract class BaseJavaUiFactory implements JavaUiFactory -{ - - // **************** java type mapping composites *************************** - - public JpaComposite createJavaMappedSuperclassComposite( - PropertyValueModel<JavaMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaMappedSuperclassComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaEntityComposite( - PropertyValueModel<JavaEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaEntityComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaEmbeddableComposite( - PropertyValueModel<JavaEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaEmbeddableComposite(subjectHolder, parent, widgetFactory); - } - - - // **************** orm type mapping composites **************************** - - public JpaComposite createOrmMappedSuperclassComposite( - PropertyValueModel<OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmMappedSuperclassComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEntityComposite( - PropertyValueModel<OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEntityComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEmbeddableComposite( - PropertyValueModel<OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEmbeddableComposite(subjectHolder, parent, widgetFactory); - } - - - // **************** java attribute mapping composites ********************** - - public JpaComposite createJavaIdMappingComposite( - PropertyValueModel<JavaIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new IdMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaEmbeddedIdMappingComposite( - PropertyValueModel<JavaEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new EmbeddedIdMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaBasicMappingComposite( - PropertyValueModel<JavaBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new BasicMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaVersionMappingComposite( - PropertyValueModel<JavaVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new VersionMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaManyToOneMappingComposite( - PropertyValueModel<JavaManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new ManyToOneMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaOneToManyMappingComposite( - PropertyValueModel<JavaOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OneToManyMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaOneToOneMappingComposite( - PropertyValueModel<JavaOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OneToOneMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaManyToManyMappingComposite( - PropertyValueModel<JavaManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new ManyToManyMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaEmbeddedMappingComposite( - PropertyValueModel<JavaEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaEmbeddedMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaTransientMappingComposite( - PropertyValueModel<JavaTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new TransientMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/DefaultBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/DefaultBasicMappingUiDefinition.java deleted file mode 100644 index fbed33d2a0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/DefaultBasicMappingUiDefinition.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractBasicMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class DefaultBasicMappingUiDefinition - extends AbstractBasicMappingUiDefinition<ReadOnlyPersistentAttribute, JavaBasicMapping> - implements DefaultJavaAttributeMappingUiDefinition<JavaBasicMapping> -{ - // singleton - private static final DefaultBasicMappingUiDefinition INSTANCE = - new DefaultBasicMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static DefaultJavaAttributeMappingUiDefinition<JavaBasicMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private DefaultBasicMappingUiDefinition() { - super(); - } - - - @Override - public String getKey() { - return null; - } - - public String getDefaultKey() { - return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY; - } - - @Override - public String getLabel() { - return JptUiDetailsMessages.DefaultBasicMappingUiProvider_label; - } - - @Override - public String getLinkLabel() { - return JptUiDetailsMessages.DefaultBasicMappingUiProvider_linkLabel; - } - - @Override - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getDefaultKey()); - } - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaBasicMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/DefaultEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/DefaultEmbeddedMappingUiDefinition.java deleted file mode 100644 index 6fed137b00..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/DefaultEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class DefaultEmbeddedMappingUiDefinition - extends AbstractEmbeddedMappingUiDefinition<ReadOnlyPersistentAttribute, JavaEmbeddedMapping> - implements DefaultJavaAttributeMappingUiDefinition<JavaEmbeddedMapping> -{ - // singleton - private static final DefaultEmbeddedMappingUiDefinition INSTANCE = - new DefaultEmbeddedMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static DefaultJavaAttributeMappingUiDefinition<JavaEmbeddedMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private DefaultEmbeddedMappingUiDefinition() { - super(); - } - - - @Override - public String getKey() { - return null; - } - - public String getDefaultKey() { - return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; - } - - @Override - public String getLabel() { - return JptUiDetailsMessages.DefaultEmbeddedMappingUiProvider_label; - } - - @Override - public String getLinkLabel() { - return JptUiDetailsMessages.DefaultEmbeddedMappingUiProvider_linkLabel; - } - - @Override - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getDefaultKey()); - } - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaEmbeddedMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/GenericJavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/GenericJavaResourceUiDefinition.java deleted file mode 100644 index 48cbee1fb8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/GenericJavaResourceUiDefinition.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.java; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; - -public class GenericJavaResourceUiDefinition extends AbstractJavaResourceUiDefinition -{ - // singleton - private static final ResourceUiDefinition INSTANCE = new GenericJavaResourceUiDefinition(); - - /** - * Return the singleton. - */ - public static ResourceUiDefinition instance() { - return INSTANCE; - } - - - /** - * zero-argument constructor - */ - protected GenericJavaResourceUiDefinition() { - super(); - } - - @Override - protected JavaUiFactory buildJavaUiFactory() { - return new GenericJavaUiFactory(); - } - - @Override - protected void addSpecifiedAttributeMappingUiDefinitionsTo( - List<JavaAttributeMappingUiDefinition<? extends AttributeMapping>> definitions) { - - definitions.add(JavaIdMappingUiDefinition.instance()); - definitions.add(JavaEmbeddedIdMappingUDefinition.instance()); - definitions.add(JavaBasicMappingUiDefinition.instance()); - definitions.add(JavaVersionMappingUiDefinition.instance()); - definitions.add(JavaManyToOneMappingUiDefinition.instance()); - definitions.add(JavaOneToManyMappingUiDefinition.instance()); - definitions.add(JavaOneToOneMappingUiDefinition.instance()); - definitions.add(JavaManyToManyMappingUiDefinition.instance()); - definitions.add(JavaEmbeddedMappingUiDefinition.instance()); - definitions.add(JavaTransientMappingUiDefinition.instance()); - } - - @Override - protected void addDefaultAttributeMappingUiDefinitionsTo(List<DefaultJavaAttributeMappingUiDefinition<?>> definitions) { - definitions.add(DefaultBasicMappingUiDefinition.instance()); - definitions.add(DefaultEmbeddedMappingUiDefinition.instance()); - definitions.add(NullJavaAttributeMappingUiDefinition.instance()); - } - - @Override - protected void addSpecifiedTypeMappingUiDefinitionsTo(List<JavaTypeMappingUiDefinition<? extends TypeMapping>> definitions) { - definitions.add(JavaEntityUiDefinition.instance()); - definitions.add(JavaMappedSuperclassUiDefinition.instance()); - definitions.add(JavaEmbeddableUiDefinition.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/GenericJavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/GenericJavaUiFactory.java deleted file mode 100644 index 7de34d3485..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/GenericJavaUiFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.java; - -/** - * The default implementation of the Java UI factory required to show the information - * related to a JPA mapping (type or attribute). - * - * @see JavaUiFactory - * - * @version 3.0 - * @since 3.0 - */ -public class GenericJavaUiFactory extends BaseJavaUiFactory -{ -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaBasicMappingUiDefinition.java deleted file mode 100644 index 466f197087..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaBasicMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractBasicMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaBasicMappingUiDefinition - extends AbstractBasicMappingUiDefinition<ReadOnlyPersistentAttribute, JavaBasicMapping> - implements JavaAttributeMappingUiDefinition<JavaBasicMapping> -{ - // singleton - private static final JavaBasicMappingUiDefinition INSTANCE = - new JavaBasicMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaBasicMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaBasicMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaBasicMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddableComposite.java deleted file mode 100644 index 18e1e4e806..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddableComposite.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Embeddable; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddableComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * This pane does not have any widgets. - * - * @see Embeddable - * @see EmbeddableUiProvider - * - * @version 2.3 - * @since 2.0 - */ -public class JavaEmbeddableComposite extends AbstractEmbeddableComposite<Embeddable> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddableComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaEmbeddableComposite(PropertyValueModel<? extends Embeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddableUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddableUiDefinition.java deleted file mode 100644 index 1c08a85eed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddableUiDefinition.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddableUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaEmbeddableUiDefinition - extends AbstractEmbeddableUiDefinition<PersistentType, JavaEmbeddable> - implements JavaTypeMappingUiDefinition<JavaEmbeddable> -{ - // singleton - private static final JavaEmbeddableUiDefinition INSTANCE = new JavaEmbeddableUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaTypeMappingUiDefinition<JavaEmbeddable> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaEmbeddableUiDefinition() { - super(); - } - - - public JpaComposite buildTypeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaEmbeddableComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddedIdMappingUDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddedIdMappingUDefinition.java deleted file mode 100644 index 4dc119c813..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddedIdMappingUDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedIdMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaEmbeddedIdMappingUDefinition - extends AbstractEmbeddedIdMappingUiDefinition<ReadOnlyPersistentAttribute, JavaEmbeddedIdMapping> - implements JavaAttributeMappingUiDefinition<JavaEmbeddedIdMapping> -{ - // singleton - private static final JavaEmbeddedIdMappingUDefinition INSTANCE = - new JavaEmbeddedIdMappingUDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaEmbeddedIdMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaEmbeddedIdMappingUDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaEmbeddedIdMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddedMappingUiDefinition.java deleted file mode 100644 index ca1c784d1a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaEmbeddedMappingUiDefinition - extends AbstractEmbeddedMappingUiDefinition<ReadOnlyPersistentAttribute, JavaEmbeddedMapping> - implements JavaAttributeMappingUiDefinition<JavaEmbeddedMapping> -{ - // singleton - private static final JavaEmbeddedMappingUiDefinition INSTANCE = - new JavaEmbeddedMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaEmbeddedMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaEmbeddedMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaEmbeddedMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEntityComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEntityComposite.java deleted file mode 100644 index 92c7659fc3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEntityComposite.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for a Java entity. - * - * @see JavaEntity - * @see JavaUiFactory - The factory creating this pane - * @see JavaSecondaryTablesComposite - * - * @version 2.3 - * @since 1.0 - */ -public class JavaEntityComposite extends AbstractEntityComposite<JavaEntity> -{ - /** - * Creates a new <code>JavaEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>JavaEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaEntityComposite(PropertyValueModel<? extends JavaEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeSecondaryTablesSection(Composite container) { - new JavaSecondaryTablesComposite(this, container); - } - - @Override - protected void initializeInheritanceSection(Composite container) { - new JavaInheritanceComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEntityUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEntityUiDefinition.java deleted file mode 100644 index 2ec685800a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaEntityUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaEntityUiDefinition - extends AbstractEntityUiDefinition<PersistentType, JavaEntity> - implements JavaTypeMappingUiDefinition<JavaEntity> -{ - // singleton - private static final JavaEntityUiDefinition INSTANCE = - new JavaEntityUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaTypeMappingUiDefinition<JavaEntity> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaEntityUiDefinition() { - super(); - } - - - public JpaComposite buildTypeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaEntityComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaIdMappingUiDefinition.java deleted file mode 100644 index 929c049a43..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaIdMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractIdMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaIdMappingUiDefinition - extends AbstractIdMappingUiDefinition<ReadOnlyPersistentAttribute, JavaIdMapping> - implements JavaAttributeMappingUiDefinition<JavaIdMapping> -{ - // singleton - private static final JavaIdMappingUiDefinition INSTANCE = - new JavaIdMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaIdMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - protected JavaIdMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaIdMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaInheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaInheritanceComposite.java deleted file mode 100644 index d029097866..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaInheritanceComposite.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractInheritanceComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for java inheritance. - * - * @see JavaEntity - * @see JavaPrimaryKeyJoinColumnsComposite - * - * @version 2.0 - * @since 1.0 - */ -public class JavaInheritanceComposite extends AbstractInheritanceComposite<JavaEntity> { - - /** - * Creates a new <code>JavaInheritanceComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public JavaInheritanceComposite(Pane<? extends JavaEntity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected void addPrimaryKeyJoinColumnsComposite(Composite container) { - new JavaPrimaryKeyJoinColumnsComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaManyToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaManyToManyMappingUiDefinition.java deleted file mode 100644 index 900ce26972..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaManyToManyMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToManyMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaManyToManyMappingUiDefinition - extends AbstractManyToManyMappingUiDefinition<ReadOnlyPersistentAttribute, JavaManyToManyMapping> - implements JavaAttributeMappingUiDefinition<JavaManyToManyMapping> -{ - // singleton - private static final JavaManyToManyMappingUiDefinition INSTANCE = - new JavaManyToManyMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaManyToManyMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaManyToManyMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaManyToManyMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaManyToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaManyToOneMappingUiDefinition.java deleted file mode 100644 index 23e70b258b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaManyToOneMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToOneMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaManyToOneMappingUiDefinition - extends AbstractManyToOneMappingUiDefinition<ReadOnlyPersistentAttribute, JavaManyToOneMapping> - implements JavaAttributeMappingUiDefinition<JavaManyToOneMapping> -{ - // singleton - private static final JavaManyToOneMappingUiDefinition INSTANCE = - new JavaManyToOneMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaManyToOneMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaManyToOneMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaManyToOneMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaMappedSuperclassComposite.java deleted file mode 100644 index 11dd635e2a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaMappedSuperclassComposite.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappedSuperclassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdClassComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | IdClassComposite | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see MappedSuperclass - * @see JavaUiFactory - The factory creating this pane - * @see IdClassComposite - * - * @version 2.3 - * @since 2.0 - */ -public class JavaMappedSuperclassComposite - extends AbstractMappedSuperclassComposite<JavaMappedSuperclass> -{ - /** - * Creates a new <code>MappedSuperclassComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaMappedSuperclassComposite( - PropertyValueModel<? extends JavaMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaMappedSuperclassUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaMappedSuperclassUiDefinition.java deleted file mode 100644 index 14d0c967d3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaMappedSuperclassUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappedSuperclassUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaMappedSuperclassUiDefinition - extends AbstractMappedSuperclassUiDefinition<PersistentType, JavaMappedSuperclass> - implements JavaTypeMappingUiDefinition<JavaMappedSuperclass> -{ - // singleton - private static final JavaMappedSuperclassUiDefinition INSTANCE = - new JavaMappedSuperclassUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaTypeMappingUiDefinition<JavaMappedSuperclass> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaMappedSuperclassUiDefinition() { - super(); - } - - - public JpaComposite buildTypeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaMappedSuperclassComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaOneToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaOneToManyMappingUiDefinition.java deleted file mode 100644 index ca30448137..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaOneToManyMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToManyMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaOneToManyMappingUiDefinition - extends AbstractOneToManyMappingUiDefinition<ReadOnlyPersistentAttribute, JavaOneToManyMapping> - implements JavaAttributeMappingUiDefinition<JavaOneToManyMapping> -{ - // singleton - private static final JavaOneToManyMappingUiDefinition INSTANCE = - new JavaOneToManyMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaOneToManyMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaOneToManyMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaOneToManyMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaOneToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaOneToOneMappingUiDefinition.java deleted file mode 100644 index d96ee6166f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaOneToOneMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToOneMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaOneToOneMappingUiDefinition - extends AbstractOneToOneMappingUiDefinition<ReadOnlyPersistentAttribute, JavaOneToOneMapping> - implements JavaAttributeMappingUiDefinition<JavaOneToOneMapping> -{ - // singleton - private static final JavaOneToOneMappingUiDefinition INSTANCE = - new JavaOneToOneMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaOneToOneMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaOneToOneMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaOneToOneMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentAttributeDetailsPage.java deleted file mode 100644 index 80046d9cbc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentAttributeDetailsPage.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.ui.internal.details.PersistentAttributeDetailsPage; -import org.eclipse.jpt.jpa.ui.internal.details.PersistentAttributeMapAsComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * The default implementation of the details page used for the Java persistent - * attribute. - * <p> - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | JavaPersistentAttributeMapAsComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | Type mapping pane | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see JavaPersistentAttribute - * @see JavaPersistentTypeMapAsComposite - * - * @version 2.2 - * @since 2.0 - */ -public class JavaPersistentAttributeDetailsPage - extends PersistentAttributeDetailsPage<JavaPersistentAttribute> -{ - /** - * Creates a new <code>JavaPersistentAttributeDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaPersistentAttributeDetailsPage(Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - // Map as composite - new PersistentAttributeMapAsComposite( - this, - addSubPane(container, 0, 0, 5, 0) - ); - - buildMappingPageBook(container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentAttributeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentAttributeDetailsProvider.java deleted file mode 100644 index b5b7691d46..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentAttributeDetailsProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.swt.widgets.Composite; - -/** - * This provider is responsible for creating the <code>JpaDetailsPage</code> - * when the information comes from the Java source file. - */ -public class JavaPersistentAttributeDetailsProvider - implements JpaDetailsProvider -{ - // singleton - private static final JpaDetailsProvider INSTANCE = new JavaPersistentAttributeDetailsProvider(); - - - /** - * Return the singleton - */ - public static JpaDetailsProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private JavaPersistentAttributeDetailsProvider() { - super(); - } - - - public boolean providesDetails(JpaStructureNode structureNode) { - return Tools.valuesAreEqual(structureNode.getId(), JavaStructureNodes.PERSISTENT_ATTRIBUTE_ID) - && structureNode.getResourceType().getContentType().equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE); - } - - public JpaDetailsPage<JavaPersistentAttribute> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new JavaPersistentAttributeDetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentTypeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentTypeDetailsProvider.java deleted file mode 100644 index f44c213cce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPersistentTypeDetailsProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.PersistentTypeDetailsPage; -import org.eclipse.swt.widgets.Composite; - -/** - * This provider is responsible for creating the <code>JpaDetailsPage</code> - * when the information comes from the Java source file. - */ -public class JavaPersistentTypeDetailsProvider - implements JpaDetailsProvider -{ - // singleton - private static final JpaDetailsProvider INSTANCE = new JavaPersistentTypeDetailsProvider(); - - - /** - * Return the singleton - */ - public static JpaDetailsProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private JavaPersistentTypeDetailsProvider() { - super(); - } - - - public boolean providesDetails(JpaStructureNode structureNode) { - return Tools.valuesAreEqual(structureNode.getId(), JavaStructureNodes.PERSISTENT_TYPE_ID) - && structureNode.getResourceType().getContentType().equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE); - } - - public JpaDetailsPage<PersistentType> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new PersistentTypeDetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java deleted file mode 100644 index 6e5f06c6cb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractPrimaryKeyJoinColumnsComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * @see JavaEntity - * @see JavaInheritanceComposite - The container of this pane - * - * @version 2.0 - * @since 2.0 - */ -public class JavaPrimaryKeyJoinColumnsComposite extends AbstractPrimaryKeyJoinColumnsComposite<JavaEntity> -{ - public JavaPrimaryKeyJoinColumnsComposite(Pane<? extends JavaEntity> subjectHolder, - Composite parent) { - - super(subjectHolder, parent); - } - - @Override - protected ListValueModel<PrimaryKeyJoinColumn> buildDefaultJoinColumnsListHolder() { - return new PropertyListValueModelAdapter<PrimaryKeyJoinColumn>(buildDefaultJoinColumnHolder()); - } - - private PropertyValueModel<PrimaryKeyJoinColumn> buildDefaultJoinColumnHolder() { - return new PropertyAspectAdapter<JavaEntity, PrimaryKeyJoinColumn>(getSubjectHolder(), JavaEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMN_PROPERTY) { - @Override - protected PrimaryKeyJoinColumn buildValue_() { - return subject.getDefaultPrimaryKeyJoinColumn(); - } - }; - } - - @Override - protected void switchDefaultToSpecified() { - PrimaryKeyJoinColumn defaultJoinColumn = getSubject().getDefaultPrimaryKeyJoinColumn(); - - if (defaultJoinColumn != null) { - String columnName = defaultJoinColumn.getDefaultName(); - String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName(); - - PrimaryKeyJoinColumn pkJoinColumn = getSubject().addSpecifiedPrimaryKeyJoinColumn(); - pkJoinColumn.setSpecifiedName(columnName); - pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName); - - this.joinColumnHolder.setValue(pkJoinColumn); - } - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaSecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaSecondaryTablesComposite.java deleted file mode 100644 index d10614b967..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaSecondaryTablesComposite.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.java; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.context.java.JavaSecondaryTable; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractSecondaryTablesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.PrimaryKeyJoinColumnsInSecondaryTableComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PrimaryKeyJoinColumnsInSecondaryTableComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see AddRemoveListPane - * @see PrimaryKeyJoinColumnsInSecondaryTableComposite - * - * @version 2.0 - * @since 1.0 - */ -public class JavaSecondaryTablesComposite extends AbstractSecondaryTablesComposite<JavaEntity> -{ - /** - * Creates a new <code>SecondaryTablesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public JavaSecondaryTablesComposite(Pane<? extends JavaEntity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Creates a new <code>SecondaryTablesComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaSecondaryTablesComposite(PropertyValueModel<? extends JavaEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - private ListValueModel<JavaSecondaryTable> buildSecondaryTablesListModel() { - return new ItemPropertyListValueModelAdapter<JavaSecondaryTable>(buildSecondaryTablesListHolder(), - ReadOnlyTable.SPECIFIED_NAME_PROPERTY); - } - - private ListValueModel<JavaSecondaryTable> buildSecondaryTablesListHolder() { - return new ListAspectAdapter<JavaEntity, JavaSecondaryTable>(getSubjectHolder(), Entity.SPECIFIED_SECONDARY_TABLES_LIST) { - @Override - protected ListIterator<JavaSecondaryTable> listIterator_() { - return this.subject.specifiedSecondaryTables(); - } - - @Override - protected int size_() { - return this.subject.specifiedSecondaryTablesSize(); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = getGroupBoxMargin(); - - WritablePropertyValueModel<SecondaryTable> secondaryTableHolder = - buildSecondaryTableHolder(); - - // Secondary Tables add/remove list pane - new AddRemoveListPane<Entity>( - this, - addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin), - buildSecondaryTablesAdapter(), - buildSecondaryTablesListModel(), - secondaryTableHolder, - buildSecondaryTableLabelProvider(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS//TODO need a help context id for this - ); - - // Primary Key Join Columns pane - new PrimaryKeyJoinColumnsInSecondaryTableComposite( - this, - secondaryTableHolder, - container - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaTransientMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaTransientMappingUiDefinition.java deleted file mode 100644 index 657e43234f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaTransientMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractTransientMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaTransientMappingUiDefinition - extends AbstractTransientMappingUiDefinition<ReadOnlyPersistentAttribute, JavaTransientMapping> - implements JavaAttributeMappingUiDefinition<JavaTransientMapping> -{ - // singleton - private static final JavaTransientMappingUiDefinition INSTANCE = - new JavaTransientMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaTransientMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaTransientMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaTransientMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaVersionMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaVersionMappingUiDefinition.java deleted file mode 100644 index d4f9bd94bc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaVersionMappingUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractVersionMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class JavaVersionMappingUiDefinition - extends AbstractVersionMappingUiDefinition<ReadOnlyPersistentAttribute, JavaVersionMapping> - implements JavaAttributeMappingUiDefinition<JavaVersionMapping> -{ - // singleton - private static final JavaVersionMappingUiDefinition INSTANCE = - new JavaVersionMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaVersionMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaVersionMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createJavaVersionMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java deleted file mode 100644 index 8e2e64812b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class NullJavaAttributeMappingUiDefinition - extends AbstractMappingUiDefinition<ReadOnlyPersistentAttribute, JavaAttributeMapping> - implements DefaultJavaAttributeMappingUiDefinition<JavaAttributeMapping> -{ - // singleton - private static final NullJavaAttributeMappingUiDefinition INSTANCE = - new NullJavaAttributeMappingUiDefinition(); - - /** - * Return the singleton. - */ - public static DefaultJavaAttributeMappingUiDefinition<JavaAttributeMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private NullJavaAttributeMappingUiDefinition() { - super(); - } - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages.NullAttributeMappingUiProvider_label; - } - - public String getLinkLabel() { - return null; - } - - public String getKey() { - return null; - } - - public String getDefaultKey() { - return MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY; - } - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaAttributeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new NullComposite(subjectHolder, parent, widgetFactory); - } - - - public static class NullComposite extends Pane<JavaAttributeMapping> - implements JpaComposite - { - NullComposite( - PropertyValueModel<JavaAttributeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) {} - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java deleted file mode 100644 index bd70844d8a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class NullJavaTypeMappingUiDefinition - extends AbstractMappingUiDefinition<PersistentType, JavaTypeMapping> - implements DefaultJavaTypeMappingUiDefinition<JavaTypeMapping> -{ - // singleton - private static final NullJavaTypeMappingUiDefinition INSTANCE = new NullJavaTypeMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static DefaultJavaTypeMappingUiDefinition<JavaTypeMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private NullJavaTypeMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForTypeMapping(null); - } - - public String getLabel() { - return JptUiDetailsMessages.NullTypeMappingUiProvider_label; - } - - public String getLinkLabel() { - return null; - } - - public String getKey() { - return null; - } - - public String getDefaultKey() { - return null; - } - - public JpaComposite buildTypeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaTypeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return new NullComposite(subjectHolder, parent, widgetFactory); - } - - public static class NullComposite - extends Pane<JavaTypeMapping> - implements JpaComposite - { - NullComposite( - PropertyValueModel<JavaTypeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) {} - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java deleted file mode 100644 index bc78d9cc89..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.orm; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractJpaDetailsPage; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | XmlPackageChooser | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------ | - * | Schema: | SchemaCombo | | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Catalog: | CatalogCombo | | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Access Type: | |v| | - * | ------------------------------------------------------------ | - * | | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitMetadataComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrmGeneratorsComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrmQueriesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EntityMappings - * @see AbstractEntityMappingsDetailsPage - The parent container - * @see CatalogCombo - * @see EnumFormComboViewer - * @see EntityMappingsGeneratorsComposite - * @see OrmPackageChooser - * @see OrmQueriesComposite - * @see PersistenceUnitMetadataComposite - * @see SchemaCombo - * - * @version 2.3 - * @since 2.0 - */ -public abstract class AbstractEntityMappingsDetailsPage extends AbstractJpaDetailsPage<EntityMappings> -{ - /** - * Creates a new <code>EntityMappingsDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractEntityMappingsDetailsPage(Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - this.initializeEntityMappingsCollapsibleSection(container); - this.initializePersistenceUnitMetadataCollapsibleSection(container); - this.initializeGeneratorsCollapsibleSection(container); - this.initializeQueriesCollapsibleSection(container); - } - - protected void initializeEntityMappingsCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsOrmMessages.EntityMappingsSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeEntityMappingsSection(container); - } - - protected void initializeEntityMappingsSection(Composite container) { - // Package widgets - new OrmPackageChooser(this, container); - - // Schema widgets - addLabeledComposite( - container, - JptUiDetailsOrmMessages.EntityMappingsDetailsPage_schema, - addSchemaCombo(container), - JpaHelpContextIds.ENTITY_ORM_SCHEMA - ); - - // Catalog widgets - addLabeledComposite( - container, - JptUiDetailsOrmMessages.EntityMappingsDetailsPage_catalog, - addCatalogCombo(container), - JpaHelpContextIds.ENTITY_ORM_CATALOG - ); - - // Access Type widgets - addLabeledComposite( - container, - JptUiDetailsOrmMessages.EntityMappingsDetailsPage_access, - addAccessTypeCombo(container), - JpaHelpContextIds.ENTITY_ORM_ACCESS - ); - } - - protected void initializePersistenceUnitMetadataCollapsibleSection(Composite container) { - new PersistenceUnitMetadataComposite( - this, - buildPersistentUnitMetadataHolder(), - addSubPane(container, 5) - ); - } - - protected EnumFormComboViewer<EntityMappings, AccessType> addAccessTypeCombo(Composite container) { - - return new EnumFormComboViewer<EntityMappings, AccessType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(EntityMappings.DEFAULT_ACCESS_PROPERTY); - propertyNames.add(EntityMappings.SPECIFIED_ACCESS_PROPERTY); - } - - @Override - protected AccessType[] getChoices() { - return AccessType.values(); - } - - @Override - protected AccessType getDefaultValue() { - return getSubject().getDefaultAccess(); - } - - @Override - protected String displayString(AccessType value) { - return value == AccessType.FIELD ? - JptUiDetailsOrmMessages.EntityMappingsDetailsPage_field : - JptUiDetailsOrmMessages.EntityMappingsDetailsPage_property; - } - - @Override - protected AccessType getValue() { - return getSubject().getSpecifiedAccess(); - } - - @Override - protected void setValue(AccessType value) { - getSubject().setSpecifiedAccess(value); - } - }; - } - - protected CatalogCombo<EntityMappings> addCatalogCombo(Composite container) { - - return new CatalogCombo<EntityMappings>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(EntityMappings.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(EntityMappings.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultCatalog(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedCatalog(); - } - }; - } - - protected PropertyValueModel<OrmPersistenceUnitMetadata> buildPersistentUnitMetadataHolder() { - return new TransformationPropertyValueModel<EntityMappings, OrmPersistenceUnitMetadata>(getSubjectHolder()) { - @Override - protected OrmPersistenceUnitMetadata transform_(EntityMappings value) { - return value.getPersistenceUnitMetadata(); - } - }; - } - - protected SchemaCombo<EntityMappings> addSchemaCombo(Composite container) { - - return new SchemaCombo<EntityMappings>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(EntityMappings.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(EntityMappings.SPECIFIED_SCHEMA_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultSchema(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - return this.getSubject().getDbSchemaContainer(); - } - - }; - } - - protected void initializeGeneratorsCollapsibleSection(Composite container) { - new EntityMappingsGeneratorsComposite( - this, - container - ); - } - - protected void initializeQueriesCollapsibleSection(Composite container) { - new OrmQueriesComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java deleted file mode 100644 index 97d8424fe4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EntityNameComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for an ORM entity. - * - * @see OrmEntity - * @see BaseJavaUiFactory - The factory creating this pane - * - * @version 2.3 - * @since 1.0 - */ -public abstract class AbstractOrmEntityComposite extends AbstractEntityComposite<OrmEntity> -{ - /** - * Creates a new <code>OrmEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>OrmEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractOrmEntityComposite( - PropertyValueModel<? extends OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) { - this.initializeEntityCollapsibleSection(container); - this.initializeQueriesCollapsibleSection(container); - this.initializeInheritanceCollapsibleSection(container); - this.initializeAttributeOverridesCollapsibleSection(container); - this.initializeGeneratorsCollapsibleSection(container); - this.initializeSecondaryTablesCollapsibleSection(container); - } - - @Override - protected void initializeEntitySection(Composite container) { - new OrmJavaClassChooser(this, getSubjectHolder(), container, false); - new TableComposite(this, container); - new EntityNameComposite(this, container); - new AccessTypeComposite(this, buildAccessHolder(), container); - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - new MetadataCompleteComposite(this, getSubjectHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<OrmEntity, AccessHolder>(getSubjectHolder()){ - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } - - @Override - protected void initializeSecondaryTablesSection(Composite container) { - new OrmSecondaryTablesComposite(this, container); - } - - @Override - protected void initializeInheritanceSection(Composite container) { - new OrmInheritanceComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java deleted file mode 100644 index db11562274..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * All the state in the definition should be "static" (i.e. unchanging once it is initialized). - */ -public abstract class AbstractOrmXmlResourceUiDefinition - implements MappingResourceUiDefinition -{ - - private OrmTypeMappingUiDefinition<? extends TypeMapping>[] ormTypeMappingUiDefinitions; - - private OrmAttributeMappingUiDefinition<? extends AttributeMapping>[] ormAttributeMappingUiDefinitions; - - private final OrmXmlUiFactory factory; - - - /** - * zero-argument constructor - */ - protected AbstractOrmXmlResourceUiDefinition() { - super(); - this.factory = buildOrmXmlUiFactory(); - } - - - protected abstract OrmXmlUiFactory buildOrmXmlUiFactory(); - - public OrmXmlUiFactory getFactory() { - return this.factory; - } - - - // ********** ORM type mappings ********** - - public JpaComposite buildTypeMappingComposite(String key, PropertyValueModel<TypeMapping> mappingHolder, Composite parent, WidgetFactory widgetFactory) { - OrmTypeMappingUiDefinition<TypeMapping> mappingUiDefinition = - (OrmTypeMappingUiDefinition<TypeMapping>) getOrmTypeMappingUiDefinition(key); - return mappingUiDefinition.buildTypeMappingComposite( - getFactory(), - mappingHolder, - parent, - widgetFactory - ); - } - - protected OrmTypeMappingUiDefinition<? extends TypeMapping> getOrmTypeMappingUiDefinition(String mappingKey) { - for (OrmTypeMappingUiDefinition<? extends TypeMapping> definition : getOrmTypeMappingUiDefinitions()) { - if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) { - return definition; - } - } - throw new IllegalArgumentException("Illegal type mapping key: " + mappingKey); //$NON-NLS-1$ - } - - public Iterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>> - typeMappingUiDefinitions() { - - return new ArrayIterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>>( - getOrmTypeMappingUiDefinitions()); - } - - protected synchronized OrmTypeMappingUiDefinition<? extends TypeMapping>[] getOrmTypeMappingUiDefinitions() { - if (this.ormTypeMappingUiDefinitions == null) { - this.ormTypeMappingUiDefinitions = this.buildOrmTypeMappingUiDefinitions(); - } - return this.ormTypeMappingUiDefinitions; - } - - - /** - * Return an array of mapping definitions to use for types in mapping files of this type. - * The order is unimportant. - */ - protected OrmTypeMappingUiDefinition<? extends TypeMapping>[] buildOrmTypeMappingUiDefinitions() { - ArrayList<OrmTypeMappingUiDefinition<? extends TypeMapping>> definitions = new ArrayList<OrmTypeMappingUiDefinition<? extends TypeMapping>>(); - this.addOrmTypeMappingUiDefinitionsTo(definitions); - @SuppressWarnings("unchecked") - OrmTypeMappingUiDefinition<? extends TypeMapping>[] definitionArray = definitions.toArray(new OrmTypeMappingUiDefinition[definitions.size()]); - return definitionArray; - } - - protected abstract void addOrmTypeMappingUiDefinitionsTo( - List<OrmTypeMappingUiDefinition<? extends TypeMapping>> definitions); - - public DefaultMappingUiDefinition<PersistentType, ? extends TypeMapping> getDefaultTypeMappingUiDefinition() { - //there is no way to choose an type in the orm.xml that doesn't have a specified mapping so we can return null here - return null; - } - - // ********** ORM attribute mappings ********** - - public JpaComposite buildAttributeMappingComposite(String key, PropertyValueModel<AttributeMapping> mappingHolder, Composite parent, WidgetFactory widgetFactory) { - - OrmAttributeMappingUiDefinition<AttributeMapping> mappingUiDefinition = - (OrmAttributeMappingUiDefinition<AttributeMapping>) getOrmAttributeMappingUiDefinition(key); - return mappingUiDefinition.buildAttributeMappingComposite( - getFactory(), - mappingHolder, - parent, - widgetFactory - ); - } - - protected OrmAttributeMappingUiDefinition<? extends AttributeMapping> getOrmAttributeMappingUiDefinition(String mappingKey) { - for (OrmAttributeMappingUiDefinition<? extends AttributeMapping> definition : getOrmAttributeMappingUiDefinitions()) { - if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) { - return definition; - } - } - return UnsupportedOrmMappingUiDefinition.instance(); - } - - public ListIterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>> attributeMappingUiDefinitions() { - return new ArrayListIterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>>( - getOrmAttributeMappingUiDefinitions()); - } - - protected synchronized OrmAttributeMappingUiDefinition<? extends AttributeMapping>[] getOrmAttributeMappingUiDefinitions() { - if (this.ormAttributeMappingUiDefinitions == null) { - this.ormAttributeMappingUiDefinitions = this.buildOrmAttributeMappingUiDefinitions(); - } - return this.ormAttributeMappingUiDefinitions; - } - - /** - * Return an array of mapping definitions to use for attributes in mapping files of this type. - * The order is unimportant. - */ - protected OrmAttributeMappingUiDefinition<? extends AttributeMapping>[] buildOrmAttributeMappingUiDefinitions() { - ArrayList<OrmAttributeMappingUiDefinition<? extends AttributeMapping>> definitions = new ArrayList<OrmAttributeMappingUiDefinition<? extends AttributeMapping>>(); - this.addOrmAttributeMappingUiDefinitionsTo(definitions); - @SuppressWarnings("unchecked") - OrmAttributeMappingUiDefinition<? extends AttributeMapping>[] definitionArray = definitions.toArray(new OrmAttributeMappingUiDefinition[definitions.size()]); - return definitionArray; - } - - protected abstract void addOrmAttributeMappingUiDefinitionsTo( - List<OrmAttributeMappingUiDefinition<? extends AttributeMapping>> definitions); - - public DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping> getDefaultAttributeMappingUiDefinition(String key) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AddGeneratorDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AddGeneratorDialog.java deleted file mode 100644 index 25619e5913..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AddGeneratorDialog.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jpt.common.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.common.ui.internal.widgets.ValidatingDialog; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticListValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Clients can use this dialog to prompt the user for SecondaryTable settings. - * Use the following once the dialog is closed: - * @see #getSelectedTable() - * @see #getSelectedCatalog() - * @see #getSelectedSchema() - * @version 2.1 - * @since 2.1 - */ -public class AddGeneratorDialog extends ValidatingDialog<AddGeneratorStateObject> { - public static final String SEQUENCE_GENERATOR = "sequenceGenerator"; //$NON-NLS-1$ - public static final String TABLE_GENERATOR = "tableGenerator"; //$NON-NLS-1$ - - /** - * The associated persistence unit - */ - private PersistenceUnit pUnit; - - // ********** constructors ********** - - /** - * Use this constructor to edit an existing conversion value - */ - public AddGeneratorDialog(Shell parent, PersistenceUnit pUnit) { - super(parent); - this.pUnit = pUnit; - } - - @Override - protected AddGeneratorStateObject buildStateObject() { - return new AddGeneratorStateObject(this.pUnit); - } - - // ********** open ********** - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(this.getTitle()); - } - - @Override - protected String getTitle() { - return JptUiDetailsOrmMessages.AddGeneratorDialog_title; - } - - @Override - protected String getDescriptionTitle() { - return JptUiDetailsOrmMessages.AddGeneratorDialog_descriptionTitle; - } - - @Override - protected String getDescription() { - return JptUiDetailsOrmMessages.AddGeneratorDialog_description; - } - - @Override - protected DialogPane<AddGeneratorStateObject> buildLayout(Composite container) { - return new GeneratorDialogPane(container); - } - - @Override - public void create() { - super.create(); - - GeneratorDialogPane pane = (GeneratorDialogPane) getPane(); - pane.selectAll(); - - getButton(OK).setEnabled(false); - } - - - // ********** public API ********** - - /** - * Return the data value set in the text widget. - */ - public String getName() { - return getSubject().getName(); - } - - /** - * Return the object value set in the text widget. - */ - public String getGeneratorType() { - return getSubject().getGeneratorType(); - } - - private class GeneratorDialogPane extends DialogPane<AddGeneratorStateObject> { - - private Text nameText; - - GeneratorDialogPane(Composite parent) { - super(AddGeneratorDialog.this.getSubjectHolder(), parent); - } - - @Override - protected void initializeLayout(Composite container) { - this.nameText = addLabeledText( - container, - JptUiDetailsOrmMessages.AddGeneratorDialog_name, - buildNameHolder() - ); - - addLabeledCombo( - container, - JptUiDetailsOrmMessages.AddGeneratorDialog_generatorType, - buildGeneratorTypeListHolder(), - buildGeneratorTypeHolder(), - buildStringConverter(), - null); - } - - protected ListValueModel<String> buildGeneratorTypeListHolder() { - List<String> generatorTypes = new ArrayList<String>(); - generatorTypes.add(TABLE_GENERATOR); - generatorTypes.add(SEQUENCE_GENERATOR); - - return new StaticListValueModel<String>(generatorTypes); - } - - private StringConverter<String> buildStringConverter() { - return new StringConverter<String>() { - public String convertToString(String value) { - if (value == TABLE_GENERATOR) { - return JptUiDetailsOrmMessages.AddGeneratorDialog_tableGenerator; - } - if (value == SEQUENCE_GENERATOR) { - return JptUiDetailsOrmMessages.AddGeneratorDialog_sequenceGenerator; - } - return value; - } - }; - } - - private WritablePropertyValueModel<String> buildNameHolder() { - return new PropertyAspectAdapter<AddGeneratorStateObject, String>(getSubjectHolder(), AddGeneratorStateObject.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getName(); - } - - @Override - protected void setValue_(String value) { - this.subject.setName(value); - } - }; - } - - private WritablePropertyValueModel<String> buildGeneratorTypeHolder() { - return new PropertyAspectAdapter<AddGeneratorStateObject, String>(getSubjectHolder(), AddGeneratorStateObject.GENERATOR_TYPE_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getGeneratorType(); - } - - @Override - protected void setValue_(String value) { - this.subject.setGeneratorType(value); - } - }; - } - - void selectAll() { - this.nameText.selectAll(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AddGeneratorStateObject.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AddGeneratorStateObject.java deleted file mode 100644 index 31b092782d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AddGeneratorStateObject.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.node.AbstractNode; -import org.eclipse.jpt.common.utility.internal.node.Node; -import org.eclipse.jpt.common.utility.internal.node.Problem; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; - -/** - * This is the state object used by the <code>AddGeneratorDialog</code>, which stores - * the current name and validates it when it is modified. - * - * @see AddGeneratorDialog - * - * @version 2.1 - * @since 2.1 - */ -final class AddGeneratorStateObject extends AbstractNode -{ - /** - * The initial name or <code>null</code> - */ - private String name; - - /** - * The initial generatorType or <code>null</code> - */ - private String generatorType; - - /** - * The <code>Validator</code> used to validate this state object. - */ - private Validator validator; - - /** - * The associated persistence unit - */ - private PersistenceUnit pUnit; - - /** - * Notifies a change in the data value property. - */ - static final String NAME_PROPERTY = "nameProperty"; //$NON-NLS-1$ - - /** - * Notifies a change in the generator type property. - */ - static final String GENERATOR_TYPE_PROPERTY = "generatorTypeProperty"; //$NON-NLS-1$ - - /** - * Creates a new <code>NewNameStateObject</code>. - * - * @param name The initial input or <code>null</code> if no initial value can - * be specified - * @param names The collection of names that can't be used or an empty - * collection if none are available - */ - AddGeneratorStateObject(PersistenceUnit pUnit) { - super(null); - this.pUnit = pUnit; - } - - private void addNameProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.name)) { - currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_nameMustBeSpecified, IMessageProvider.ERROR)); - } - else if (names().contains(this.name)){ - currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_nameExists, IMessageProvider.WARNING)); - } - } - - private void addGeneratorTypeProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.generatorType)) { - currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_typeMustBeSpecified, IMessageProvider.ERROR)); - } - } - - @Override - protected void addProblemsTo(List<Problem> currentProblems) { - super.addProblemsTo(currentProblems); - addNameProblemsTo(currentProblems); - addGeneratorTypeProblemsTo(currentProblems); - } - - private List<String> names() { - List<String> names = new ArrayList<String>(); - for (Iterator<Generator> generators = this.pUnit.generators(); generators.hasNext();){ - String name = generators.next().getName(); - names.add(name); - } - return names; - } - - @Override - protected void checkParent(Node parentNode) { - //no parent - } - - public String displayString() { - return null; - } - - String getName() { - return this.name; - } - - String getGeneratorType() { - return this.generatorType; - } - - public void setName(String newName) { - String oldName = this.name; - this.name = newName; - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public void setGeneratorType(String newGeneratorType) { - String old = this.generatorType; - this.generatorType = newGeneratorType; - firePropertyChanged(GENERATOR_TYPE_PROPERTY, old, newGeneratorType); - } - - @Override - public void setValidator(Validator validator) { - this.validator = validator; - } - - @Override - public Validator getValidator() { - return this.validator; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/BaseOrmXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/BaseOrmXmlUiFactory.java deleted file mode 100644 index d44d8d6e49..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/BaseOrmXmlUiFactory.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.TransientMappingComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * The default implementation of the Orm Xml UI factory required to show the information - * related to a JPA mapping (type or attribute). - */ -public abstract class BaseOrmXmlUiFactory implements OrmXmlUiFactory -{ - - // **************** orm type mapping composites **************************** - - public JpaComposite createOrmMappedSuperclassComposite( - PropertyValueModel<OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmMappedSuperclassComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEntityComposite( - PropertyValueModel<OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEntityComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEmbeddableComposite( - PropertyValueModel<OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEmbeddableComposite(subjectHolder, parent, widgetFactory); - } - - - // **************** orm attribute mapping composites *********************** - - public JpaComposite createOrmIdMappingComposite( - PropertyValueModel<OrmIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmIdMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEmbeddedIdMappingComposite( - PropertyValueModel<OrmEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEmbeddedIdMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmBasicMappingComposite( - PropertyValueModel<OrmBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmBasicMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmVersionMappingComposite( - PropertyValueModel<OrmVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmVersionMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmManyToOneMappingComposite( - PropertyValueModel<OrmManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmManyToOneMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmOneToManyMappingComposite( - PropertyValueModel<OrmOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmOneToManyMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmOneToOneMappingComposite( - PropertyValueModel<OrmOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmOneToOneMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmManyToManyMappingComposite( - PropertyValueModel<OrmManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmManyToManyMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEmbeddedMappingComposite( - PropertyValueModel<OrmEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEmbeddedMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmTransientMappingComposite( - PropertyValueModel<OrmTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new TransientMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsDetailsPage.java deleted file mode 100644 index 0c9ec4c6df..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsDetailsPage.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | XmlPackageChooser | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------ | - * | Schema: | SchemaCombo | | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Catalog: | CatalogCombo | | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Access Type: | |v| | - * | ------------------------------------------------------------ | - * | | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitMetadataComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrmGeneratorsComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrmQueriesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EntityMappings - * @see EntityMappingsDetailsPage - The parent container - * @see CatalogCombo - * @see EnumFormComboViewer - * @see EntityMappingsGeneratorsComposite - * @see OrmPackageChooser - * @see OrmQueriesComposite - * @see PersistenceUnitMetadataComposite - * @see SchemaCombo - * - * @version 2.2 - * @since 2.0 - */ -public class EntityMappingsDetailsPage extends AbstractEntityMappingsDetailsPage -{ - /** - * Creates a new <code>EntityMappingsDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public EntityMappingsDetailsPage(Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsDetailsProvider.java deleted file mode 100644 index 0d9435573c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsDetailsProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityMappingsDetailsProvider; -import org.eclipse.swt.widgets.Composite; - -/** - * This provider is responsible for creating the {@link JpaDetailsPage} - * when the information comes from the XML file (either from the persistence - * configuration or from the Mappings Descriptor). - */ -public class EntityMappingsDetailsProvider - extends AbstractEntityMappingsDetailsProvider -{ - // singleton - private static final JpaDetailsProvider INSTANCE = new EntityMappingsDetailsProvider(); - - - /** - * Return the singleton - */ - public static JpaDetailsProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private EntityMappingsDetailsProvider() { - super(); - } - - - @Override - protected boolean providesDetails(JptResourceType resourceType) { - return resourceType.equals(JptJpaCorePlugin.ORM_XML_1_0_RESOURCE_TYPE); - } - - public JpaDetailsPage<EntityMappings> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new EntityMappingsDetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java deleted file mode 100644 index 0519124a20..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java +++ /dev/null @@ -1,371 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.context.TableGenerator; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmGenerator; -import org.eclipse.jpt.jpa.core.context.orm.OrmSequenceGenerator; -import org.eclipse.jpt.jpa.core.context.orm.OrmTableGenerator; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite; -import org.eclipse.jpt.jpa.ui.internal.details.SequenceGeneratorComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TableGeneratorComposite; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -/** - * This pane shows the list of named queries and named native queries. - * <p> - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrmSequenceGeneratorComposite or OrmTableGeneratorComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EntityMappings - * @see OrmGenerator - * @see OrmSequenceGenerator - * @see OrmTableGenerator - * @see EntityComposite - The parent container - * @see OrmSequenceGeneratorComposite - * @see OrmTableGeneratorComposite - * - * @version 2.2 - * @since 2.0 - */ -public class EntityMappingsGeneratorsComposite extends Pane<EntityMappings> -{ - private WritablePropertyValueModel<OrmGenerator> generatorHolder; - GeneratorComposite<SequenceGenerator> sequenceGeneratorPane; - TableGeneratorComposite tableGeneratorPane; - private AddRemoveListPane<EntityMappings> listPane; - - /** - * Creates a new <code>EntityMappingsGeneratorsComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public EntityMappingsGeneratorsComposite( - Pane<? extends EntityMappings> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - void addGenerator(ObjectListSelectionModel listSelectionModel) { - addGeneratorFromDialog(listSelectionModel, buildAddGeneratorDialog()); - } - - protected AddGeneratorDialog buildAddGeneratorDialog() { - return new AddGeneratorDialog(getShell(), this.getSubject().getPersistenceUnit()); - } - - protected void addGeneratorFromDialog(ObjectListSelectionModel listSelectionModel, AddGeneratorDialog dialog) { - if (dialog.open() != Window.OK) { - return; - } - String generatorType = dialog.getGeneratorType(); - OrmGenerator generator; - if (generatorType == AddGeneratorDialog.TABLE_GENERATOR) { - generator = this.getSubject().addTableGenerator(); - } - else if (generatorType == AddGeneratorDialog.SEQUENCE_GENERATOR) { - generator = this.getSubject().addSequenceGenerator(); - } - else { - throw new IllegalArgumentException(); - } - generator.setName(dialog.getName()); - this.generatorHolder.setValue(generator);//so that it gets selected in the List for the user to edit - listSelectionModel.setSelectedValue(generator); - } - - private ListValueModel<OrmGenerator> buildDisplayableGeneratorListHolder() { - return new ItemPropertyListValueModelAdapter<OrmGenerator>( - buildGeneratorsListHolder(), - JpaNamedContextNode.NAME_PROPERTY - ); - } - - private Adapter buildGeneratorAdapter() { - - return new AddRemoveListPane.AbstractAdapter() { - - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addGenerator(listSelectionModel); - } - - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - if (item instanceof OrmSequenceGenerator) { - getSubject().removeSequenceGenerator((OrmSequenceGenerator) item); - } - else { - getSubject().removeTableGenerator((OrmTableGenerator) item); - } - } - } - }; - } - - private WritablePropertyValueModel<OrmGenerator> buildGeneratorHolder() { - return new SimplePropertyValueModel<OrmGenerator>(); - } - - private ILabelProvider buildGeneratorLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - OrmGenerator generator = (OrmGenerator) element; - String name = generator.getName(); - - if (name == null) { - int index = -1; - - if (generator instanceof OrmSequenceGenerator) { - index = CollectionTools.indexOf(getSubject().getSequenceGenerators(), generator); - } - else { - index = CollectionTools.indexOf(getSubject().getTableGenerators(), generator); - } - - name = NLS.bind(JptUiDetailsOrmMessages.OrmGeneratorsComposite_displayString, Integer.valueOf(index)); - } - - return name; - } - }; - } - - private ListValueModel<OrmGenerator> buildGeneratorsListHolder() { - List<ListValueModel<? extends OrmGenerator>> list = new ArrayList<ListValueModel<? extends OrmGenerator>>(); - list.add(buildSequenceGeneratorListHolder()); - list.add(buildTableGeneratorListHolder()); - return new CompositeListValueModel<ListValueModel<? extends OrmGenerator>, OrmGenerator>(list); - } - - private PropertyValueModel<Boolean> buildPaneEnablerHolder() { - return new TransformationPropertyValueModel<EntityMappings, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(EntityMappings value) { - return Boolean.valueOf(value != null); - } - }; - } - - private Transformer<OrmGenerator, Control> buildPaneTransformer() { - return new Transformer<OrmGenerator, Control>() { - public Control transform(OrmGenerator generator) { - - if (generator == null) { - return null; - } - - if (generator instanceof OrmSequenceGenerator) { - return EntityMappingsGeneratorsComposite.this.sequenceGeneratorPane.getControl(); - } - - return EntityMappingsGeneratorsComposite.this.tableGeneratorPane.getControl(); - } - }; - } - - private PropertyValueModel<SequenceGenerator> buildSequenceGeneratorHolder() { - return new TransformationPropertyValueModel<OrmGenerator, SequenceGenerator>(this.generatorHolder) { - @Override - protected SequenceGenerator transform_(OrmGenerator value) { - return (value instanceof SequenceGenerator) ? (SequenceGenerator) value : null; - } - }; - } - - private ListValueModel<OrmSequenceGenerator> buildSequenceGeneratorListHolder() { - return new ListAspectAdapter<EntityMappings, OrmSequenceGenerator>( - getSubjectHolder(), - EntityMappings.SEQUENCE_GENERATORS_LIST) - { - @Override - protected ListIterable<OrmSequenceGenerator> getListIterable() { - return this.subject.getSequenceGenerators(); - } - @Override - protected int size_() { - return this.subject.getSequenceGeneratorsSize(); - } - }; - } - - private PropertyValueModel<TableGenerator> buildTableGeneratorHolder() { - return new TransformationPropertyValueModel<OrmGenerator, TableGenerator>(this.generatorHolder) { - @Override - protected TableGenerator transform_(OrmGenerator value) { - return (value instanceof TableGenerator) ? (TableGenerator) value : null; - } - }; - } - - private ListValueModel<OrmTableGenerator> buildTableGeneratorListHolder() { - return new ListAspectAdapter<EntityMappings, OrmTableGenerator>( - getSubjectHolder(), - EntityMappings.TABLE_GENERATORS_LIST) - { - @Override - protected ListIterable<OrmTableGenerator> getListIterable() { - return this.subject.getTableGenerators(); - } - @Override - protected int size_() { - return this.subject.getTableGeneratorsSize(); - } - }; - } - - - @Override - protected void initialize() { - super.initialize(); - this.generatorHolder = buildGeneratorHolder(); - } - - @Override - protected void initializeLayout(Composite container) { - - container = addCollapsibleSection( - container, - JptUiDetailsOrmMessages.OrmGeneratorsComposite_groupBox - ); - - // List pane - this.listPane = addListPane(container); - this.installPaneEnabler(); - - // Property pane - PropertyValueModel<SequenceGenerator> sequenceGeneratorHolder = - this.buildSequenceGeneratorHolder(); - PropertyValueModel<TableGenerator> tableGeneratorHolder = - this.buildTableGeneratorHolder(); - - PageBook pageBook = new PageBook(container, SWT.NULL); - pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // Sequence Generator property pane - this.sequenceGeneratorPane = this.buildSequenceGeneratorComposite( - pageBook, - sequenceGeneratorHolder, - this.buildSequenceGeneratorBuilder() - ); - - // Table Generator property pane - this.tableGeneratorPane = new TableGeneratorComposite( - this, - tableGeneratorHolder, - pageBook, - this.buildTableGeneratorBuilder() - ); - - this.addAlignRight(this.sequenceGeneratorPane); - this.addAlignRight(this.tableGeneratorPane); - this.installPaneSwitcher(pageBook); - } - - protected GeneratorComposite<SequenceGenerator> buildSequenceGeneratorComposite( - Composite parent, - PropertyValueModel<SequenceGenerator> sequenceGeneratorHolder, - GeneratorBuilder<SequenceGenerator> generatorBuilder) { - - return new SequenceGeneratorComposite( - this, - sequenceGeneratorHolder, - parent, - generatorBuilder - ); - } - - private AddRemoveListPane<EntityMappings> addListPane(Composite container) { - - return new AddRemoveListPane<EntityMappings>( - this, - container, - this.buildGeneratorAdapter(), - this.buildDisplayableGeneratorListHolder(), - this.generatorHolder, - this.buildGeneratorLabelProvider() - ); - } - - private void installPaneEnabler() { - new PaneEnabler( - this.buildPaneEnablerHolder(), - this.listPane - ); - } - - private void installPaneSwitcher(PageBook pageBook) { - new ControlSwitcher(this.generatorHolder, this.buildPaneTransformer(), pageBook); - } - - private GeneratorBuilder<SequenceGenerator> buildSequenceGeneratorBuilder() { - return new GeneratorBuilder<SequenceGenerator>() { - public SequenceGenerator addGenerator() { - throw new UnsupportedOperationException("The sequence generator will never be null so we do not need to implement this"); //$NON-NLS-1$ - } - }; - } - - private GeneratorBuilder<TableGenerator> buildTableGeneratorBuilder() { - return new GeneratorBuilder<TableGenerator>() { - public TableGenerator addGenerator() { - throw new UnsupportedOperationException("The table generator will never be null so we do not need to implement this"); //$NON-NLS-1$ - } - }; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/GenericOrmXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/GenericOrmXmlUiFactory.java deleted file mode 100644 index 5ea741c22d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/GenericOrmXmlUiFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.details.orm; - -public class GenericOrmXmlUiFactory extends BaseOrmXmlUiFactory -{ - //nothing -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/JptUiDetailsOrmMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/JptUiDetailsOrmMessages.java deleted file mode 100644 index e2db1608ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/JptUiDetailsOrmMessages.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.orm; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali ORM widgets. - * - * @version 2.2 - * @since 1.0 - */ -public class JptUiDetailsOrmMessages { - - public static String EntityMappingsSection_title; - public static String EntityMappingsDetailsPage_access; - public static String EntityMappingsDetailsPage_catalog; - public static String EntityMappingsDetailsPage_field; - public static String EntityMappingsDetailsPage_package; - public static String EntityMappingsDetailsPage_property; - public static String EntityMappingsDetailsPage_schema; - public static String EntityMappingsPage_catalogDefault; - public static String EntityMappingsPage_catalogNoDefaultSpecified; - public static String EntityMappingsPage_schemaDefault; - public static String EntityMappingsPage_schemaNoDefaultSpecified; - public static String MetadataCompleteComposite_metadataComplete; - public static String MetadataCompleteComposite_metadataCompleteWithDefault; - public static String OrmGeneratorsComposite_displayString; - public static String OrmGeneratorsComposite_groupBox; - public static String OrmMappingNameChooser_name; - public static String OrmJavaClassChooser_javaClass; - public static String OrmQueriesComposite_groupBox; - public static String PersistenceUnitMetadataComposite_access; - public static String PersistenceUnitMetadataComposite_delimitedIdentifiersCheckBox; - public static String PersistenceUnitMetadataComposite_cascadePersistCheckBox; - public static String PersistenceUnitMetadataComposite_catalog; - public static String PersistenceUnitMetadataComposite_field; - public static String PersistenceUnitMetadataComposite_persistenceUnitSection; - public static String PersistenceUnitMetadataComposite_property; - public static String PersistenceUnitMetadataComposite_schema; - public static String PersistenceUnitMetadataComposite_xmlMappingMetadataCompleteCheckBox; - public static String PersistenceUnitMetadataSection_catalogDefault; - public static String PersistenceUnitMetadataSection_schemaDefault; - - public static String AddGeneratorDialog_name; - public static String AddGeneratorDialog_generatorType; - public static String AddGeneratorDialog_title; - public static String AddGeneratorDialog_descriptionTitle; - public static String AddGeneratorDialog_description; - public static String AddGeneratorDialog_tableGenerator; - public static String AddGeneratorDialog_sequenceGenerator; - public static String GeneratorStateObject_nameExists; - public static String GeneratorStateObject_nameMustBeSpecified; - public static String GeneratorStateObject_typeMustBeSpecified; - - public static String UnsupportedOrmMappingUiProvider_label; - public static String UnsupportedOrmMappingUiProvider_linkLabel; - - private static final String BUNDLE_NAME = "jpt_ui_details_orm"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiDetailsOrmMessages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiDetailsOrmMessages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/MetadataCompleteComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/MetadataCompleteComposite.java deleted file mode 100644 index 62d4f60ce5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/MetadataCompleteComposite.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -public class MetadataCompleteComposite extends Pane<OrmTypeMapping> { - - public MetadataCompleteComposite(Pane<?> parentPane, - PropertyValueModel<? extends OrmTypeMapping> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - // TODO not sure the is the right thing to do; since metadata complete - // has an "override" (from the persistence unit), not a default... - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsOrmMessages.MetadataCompleteComposite_metadataComplete, - buildMetadataCompleteHolder(), - buildMetadataCompleteStringHolder(), - null - ); - } - - private WritablePropertyValueModel<Boolean> buildMetadataCompleteHolder() { - return new PropertyAspectAdapter<OrmTypeMapping, Boolean>( - getSubjectHolder(), - OrmTypeMapping.SPECIFIED_METADATA_COMPLETE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedMetadataComplete(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedMetadataComplete(value); - } - }; - } - - private PropertyValueModel<String> buildMetadataCompleteStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildOverrideMetadataCompleteHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsOrmMessages.MetadataCompleteComposite_metadataCompleteWithDefault, defaultStringValue); - } - return JptUiDetailsOrmMessages.MetadataCompleteComposite_metadataComplete; - } - }; - } - private PropertyValueModel<Boolean> buildOverrideMetadataCompleteHolder() { - return new PropertyAspectAdapter<OrmTypeMapping, Boolean>( - getSubjectHolder(), - OrmTypeMapping.SPECIFIED_METADATA_COMPLETE_PROPERTY, - OrmTypeMapping.OVERRIDE_METADATA_COMPLETE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedMetadataComplete() != null) { - return null; - } - return Boolean.valueOf(this.subject.isOverrideMetadataComplete()); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmBasicMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmBasicMappingComposite.java deleted file mode 100644 index 60f453b983..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmBasicMappingComposite.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractBasicMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmBasicMappingComposite extends AbstractBasicMappingComposite<BasicMapping> -{ - /** - * Creates a new <code>EclipseLink1_1OrmBasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>BasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmBasicMappingComposite(PropertyValueModel<? extends BasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeBasicSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, addSubPane(container, 4)); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmBasicMappingUiDefinition.java deleted file mode 100644 index febf82f355..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmBasicMappingUiDefinition.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractBasicMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmBasicMappingUiDefinition - extends AbstractBasicMappingUiDefinition<ReadOnlyPersistentAttribute, OrmBasicMapping> - implements OrmAttributeMappingUiDefinition<OrmBasicMapping> -{ - // singleton - private static final OrmBasicMappingUiDefinition INSTANCE = - new OrmBasicMappingUiDefinition(); - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmBasicMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmBasicMappingUiDefinition() { - super(); - } - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmBasicMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddableComposite.java deleted file mode 100644 index 6717dbe577..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddableComposite.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddableComposite extends AbstractEmbeddableComposite<OrmEmbeddable> implements JpaComposite -{ - public OrmEmbeddableComposite(PropertyValueModel<? extends OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - this.initializeEmbeddableCollapsibleSection(container); - } - - @Override - protected void initializeEmbeddableSection(Composite container) { - new OrmJavaClassChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolder(), container); - new MetadataCompleteComposite(this, getSubjectHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<OrmEmbeddable, AccessHolder>( - getSubjectHolder()) - { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddableUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddableUiDefinition.java deleted file mode 100644 index 9d611ac30e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddableUiDefinition.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddableUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddableUiDefinition - extends AbstractEmbeddableUiDefinition<PersistentType, OrmEmbeddable> - implements OrmTypeMappingUiDefinition<OrmEmbeddable> -{ - // singleton - private static final OrmEmbeddableUiDefinition INSTANCE = new OrmEmbeddableUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmTypeMappingUiDefinition<OrmEmbeddable> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmEmbeddableUiDefinition() { - super(); - } - - - public JpaComposite buildTypeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmEmbeddableComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedIdMappingComposite.java deleted file mode 100644 index 939321c5d3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedIdMappingComposite.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EmbeddedMappingOverridesComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddedIdMappingComposite - extends AbstractEmbeddedIdMappingComposite<EmbeddedIdMapping> -{ - public OrmEmbeddedIdMappingComposite( - PropertyValueModel<? extends EmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeEmbeddedIdSection(Composite container) { - new OrmMappingNameChooser(this, getSubjectHolder(), container); - - new EmbeddedMappingOverridesComposite( - this, - container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedIdMappingUiDefinition.java deleted file mode 100644 index 9d8a08c1ff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedIdMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedIdMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddedIdMappingUiDefinition - extends AbstractEmbeddedIdMappingUiDefinition<ReadOnlyPersistentAttribute, OrmEmbeddedIdMapping> - implements OrmAttributeMappingUiDefinition<OrmEmbeddedIdMapping> -{ - // singleton - private static final OrmEmbeddedIdMappingUiDefinition INSTANCE = - new OrmEmbeddedIdMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmEmbeddedIdMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmEmbeddedIdMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmEmbeddedIdMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedMappingComposite.java deleted file mode 100644 index 44a45c4e49..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedMappingComposite.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EmbeddedMappingOverridesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * @see BaseJavaUiFactory - The factory creating this pane - * - * @version 2.3 - * @since 2.2 - */ -public class OrmEmbeddedMappingComposite - extends AbstractEmbeddedMappingComposite<EmbeddedMapping> -{ - /** - * Creates a new <code>EmbeddedMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>EmbeddedMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmEmbeddedMappingComposite(PropertyValueModel<? extends EmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeEmbeddedSection(Composite container) { - new OrmMappingNameChooser(this, getSubjectHolder(), container); - - new EmbeddedMappingOverridesComposite( - this, - container - ); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedMappingUiDefinition.java deleted file mode 100644 index 532f197eb0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddedMappingUiDefinition - extends AbstractEmbeddedMappingUiDefinition<ReadOnlyPersistentAttribute, OrmEmbeddedMapping> - implements OrmAttributeMappingUiDefinition<OrmEmbeddedMapping> -{ - // singleton - private static final OrmEmbeddedMappingUiDefinition INSTANCE = - new OrmEmbeddedMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmEmbeddedMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmEmbeddedMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmEmbeddedMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEntityComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEntityComposite.java deleted file mode 100644 index ebbbcdbcfd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEntityComposite.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for an ORM entity. - * - * @see OrmEntity - * @see BaseJavaUiFactory - The factory creating this pane - * @see OrmSecondaryTablesComposite - * - * @version 2.0 - * @since 1.0 - */ -public class OrmEntityComposite extends AbstractOrmEntityComposite -{ - /** - * Creates a new <code>OrmEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>OrmEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmEntityComposite(PropertyValueModel<? extends OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEntityUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEntityUiDefinition.java deleted file mode 100644 index 28ec546536..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmEntityUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmEntityUiDefinition - extends AbstractEntityUiDefinition<PersistentType, OrmEntity> - implements OrmTypeMappingUiDefinition<OrmEntity> -{ - // singleton - private static final OrmEntityUiDefinition INSTANCE = - new OrmEntityUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmTypeMappingUiDefinition<OrmEntity> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmEntityUiDefinition() { - super(); - } - - - public JpaComposite buildTypeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmEntityComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmIdMappingComposite.java deleted file mode 100644 index 83fb1c9850..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmIdMappingComposite.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmIdMappingComposite - extends AbstractIdMappingComposite<IdMapping> -{ - public OrmIdMappingComposite( - PropertyValueModel<? extends IdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeIdSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmIdMappingUiDefinition.java deleted file mode 100644 index a66e67eba2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmIdMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractIdMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmIdMappingUiDefinition - extends AbstractIdMappingUiDefinition<ReadOnlyPersistentAttribute, OrmIdMapping> - implements OrmAttributeMappingUiDefinition<OrmIdMapping> -{ - // singleton - private static final OrmIdMappingUiDefinition INSTANCE = - new OrmIdMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmIdMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmIdMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmIdMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmInheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmInheritanceComposite.java deleted file mode 100644 index cbeadd2cd5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmInheritanceComposite.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractInheritanceComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for java inheritance. - * - * @see OrmEntity - * @see OrmPrimaryKeyJoinColumnsComposite - * - * @version 2.0 - * @since 1.0 - */ -public class OrmInheritanceComposite extends AbstractInheritanceComposite<OrmEntity> { - - /** - * Creates a new <code>OrmInheritanceComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OrmInheritanceComposite(Pane<? extends OrmEntity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected void addPrimaryKeyJoinColumnsComposite(Composite container) { - new OrmPrimaryKeyJoinColumnsComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java deleted file mode 100644 index eaadc6576c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | ClassChooserPane | - * | | - * -----------------------------------------------------------------------------</pre> - * - * TODO possibly help the user and if they have chosen a package at the - * entity-mappings level only insert the class name in the xml file if they - * choose a class from the package. - * Not sure if this should be driven by the UI or by ui api in the model - * - * @see OrmTypeMapping - * @see OrmPersistentTypeDetailsPage - The parent container - * @see ClassChooserPane - * - * @version 2.0 - * @since 1.0 - */ -public class OrmJavaClassChooser extends Pane<OrmTypeMapping> { - - /** - * Creates a new <code>XmlJavaClassChooser</code>. - * - * @param parentPane The parent controller of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public OrmJavaClassChooser(Pane<?> parentPane, - PropertyValueModel<? extends OrmTypeMapping> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - public OrmJavaClassChooser(Pane<?> parentPane, - PropertyValueModel<? extends OrmTypeMapping> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets); - } - - - private ClassChooserPane<OrmTypeMapping> addClassChooser(Composite container) { - - return new ClassChooserPane<OrmTypeMapping>(this, container) { - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<OrmTypeMapping, String>(getSubjectHolder(), OrmTypeMapping.CLASS_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getClass_(); - } - - @Override - protected void setValue_(String value) { - this.subject.setClass(value); - } - }; - } - - @Override - protected String getClassName() { - return getSubject().getClass_(); - } - - @Override - protected String getLabelText() { - return JptUiDetailsOrmMessages.OrmJavaClassChooser_javaClass; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected void setClassName(String className) { - getSubject().setClass(className); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - addClassChooser(container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToManyMappingComposite.java deleted file mode 100644 index 21a0743a69..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToManyMappingComposite.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.ManyToManyRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.CascadeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ManyToManyJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.OrderingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrderingComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToManyMapping} - * @see {@link TargetEntityComposite} - * @see {@link ManyToManyJoiningStrategyPane} - * @see {@link FetchTypeComposite} - * @see {@link CascadeComposite} - * @see {@link OrderingComposite} - * - * @version 2.3 - * @since 1.0 - */ -public class OrmManyToManyMappingComposite - extends AbstractManyToManyMappingComposite<ManyToManyMapping, ManyToManyRelationship> -{ - /** - * Creates a new <code>ManyToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IManyToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmManyToManyMappingComposite(PropertyValueModel<? extends ManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeManyToManySection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new FetchTypeComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToManyMappingUiDefinition.java deleted file mode 100644 index ee2e44615a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToManyMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToManyMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmManyToManyMappingUiDefinition - extends AbstractManyToManyMappingUiDefinition<ReadOnlyPersistentAttribute, OrmManyToManyMapping> - implements OrmAttributeMappingUiDefinition<OrmManyToManyMapping> -{ - // singleton - private static final OrmManyToManyMappingUiDefinition INSTANCE = - new OrmManyToManyMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmManyToManyMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmManyToManyMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmManyToManyMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToOneMappingComposite.java deleted file mode 100644 index 8cb0a652c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToOneMappingComposite.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToOneMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.CascadeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ManyToOneJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToOneMapping} - * @see {@link TargetEntityComposite} - * @see {@link ManyToOneJoiningStrategyPane} - * @see {@link FetchTypeComposite} - * @see {@link OptionalComposite} - * @see {@link CascadeComposite} - * - * @version 2.3 - * @since 1.0 - */ -public class OrmManyToOneMappingComposite - extends AbstractManyToOneMappingComposite<OrmManyToOneMapping, OrmManyToOneRelationship> -{ - /** - * Creates a new <code>ManyToOneMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IManyToOneMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmManyToOneMappingComposite(PropertyValueModel<? extends OrmManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeManyToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToOneMappingUiDefinition.java deleted file mode 100644 index 2738762508..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmManyToOneMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToOneMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmManyToOneMappingUiDefinition - extends AbstractManyToOneMappingUiDefinition<ReadOnlyPersistentAttribute, OrmManyToOneMapping> - implements OrmAttributeMappingUiDefinition<OrmManyToOneMapping> -{ - // singleton - private static final OrmManyToOneMappingUiDefinition INSTANCE = - new OrmManyToOneMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmManyToOneMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmManyToOneMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmManyToOneMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java deleted file mode 100644 index b26ea5dd75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappedSuperclassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdClassComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmMappedSuperclassComposite - extends AbstractMappedSuperclassComposite<OrmMappedSuperclass> - implements JpaComposite -{ - public OrmMappedSuperclassComposite( - PropertyValueModel<? extends OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeMappedSuperclassSection(Composite container) { - new OrmJavaClassChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolder(), container); - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - new MetadataCompleteComposite(this, getSubjectHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<OrmMappedSuperclass, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassUiDefinition.java deleted file mode 100644 index 3b919460e1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassUiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappedSuperclassUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmMappedSuperclassUiDefinition - extends AbstractMappedSuperclassUiDefinition<PersistentType, OrmMappedSuperclass> - implements OrmTypeMappingUiDefinition<OrmMappedSuperclass> -{ - // singleton - private static final OrmMappedSuperclassUiDefinition INSTANCE = - new OrmMappedSuperclassUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmTypeMappingUiDefinition<OrmMappedSuperclass> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmMappedSuperclassUiDefinition() { - super(); - } - - - public JpaComposite buildTypeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmMappedSuperclassComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappingNameChooser.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappingNameChooser.java deleted file mode 100644 index 1dc11a6f49..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappingNameChooser.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.swt.widgets.Composite; - -/** - * @see OrmPersistentAttributeDetailsPage - The parent container - * - * @version 2.3 - * @since 1.0 - */ -public class OrmMappingNameChooser - extends Pane<AttributeMapping> -{ - /** - * Creates a new <code>XmlJavaAttributeChooser</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public OrmMappingNameChooser(Pane<?> parentPane, - PropertyValueModel<? extends AttributeMapping> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - this.addLabeledText( - container, - JptUiDetailsOrmMessages.OrmMappingNameChooser_name, - buildNameHolder() - ); - } - private WritablePropertyValueModel<String> buildNameHolder() { - return new PropertyAspectAdapter<AttributeMapping, String>(getSubjectHolder(), OrmAttributeMapping.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getName(); - } - - @Override - protected void setValue_(String value) { - if (this.subject.getPersistentAttribute().isVirtual()) { - return; - } - if (value.length() == 0) { - value = null; - } - // we can safely cast to an orm.xml mapping since it is not virtual - ((OrmAttributeMapping) this.subject).setName(value); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToManyMappingComposite.java deleted file mode 100644 index da0df67b48..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToManyMappingComposite.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToManyMapping; -import org.eclipse.jpt.jpa.core.context.OneToManyRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.CascadeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JoinTableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OrderingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrderingComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OneToManyMapping - * @see CascadeComposite - * @see FetchTypeComposite - * @see JoinTableComposite - * @see OrderingComposite - * @see TargetEntityComposite - * - * @version 2.3 - * @since 1.0 - */ -public class OrmOneToManyMappingComposite - extends AbstractOneToManyMappingComposite<OneToManyMapping, OneToManyRelationship> -{ - /** - * Creates a new <code>OneToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IOneToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmOneToManyMappingComposite(PropertyValueModel<? extends OneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeOneToManySection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new FetchTypeComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToManyMappingUiDefinition.java deleted file mode 100644 index f899ac6b7c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToManyMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToManyMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmOneToManyMappingUiDefinition - extends AbstractOneToManyMappingUiDefinition<ReadOnlyPersistentAttribute, OrmOneToManyMapping> - implements OrmAttributeMappingUiDefinition<OrmOneToManyMapping> -{ - // singleton - private static final OrmOneToManyMappingUiDefinition INSTANCE = - new OrmOneToManyMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmOneToManyMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmOneToManyMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmOneToManyMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToOneMappingComposite.java deleted file mode 100644 index e072ae3c81..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToOneMappingComposite.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.core.context.OneToOneRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToOneMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.CascadeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetEntityComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | JoiningStrategyComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CascadeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OneToOneMapping - * @see TargetEntityComposite - * @see JoiningStrategyComposite - * @see FetchTypeComposite - * @see OptionalComposite - * @see CascadeComposite - * - * @version 2.3 - * @since 1.0 - */ -public class OrmOneToOneMappingComposite - extends AbstractOneToOneMappingComposite<OneToOneMapping, OneToOneRelationship> -{ - /** - * Creates a new <code>OneToOneMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IOneToOneMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmOneToOneMappingComposite(PropertyValueModel<? extends OneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeOneToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToOneMappingUiDefinition.java deleted file mode 100644 index c37fa42c50..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmOneToOneMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToOneMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmOneToOneMappingUiDefinition - extends AbstractOneToOneMappingUiDefinition<ReadOnlyPersistentAttribute, OrmOneToOneMapping> - implements OrmAttributeMappingUiDefinition<OrmOneToOneMapping> -{ - // singleton - private static final OrmOneToOneMappingUiDefinition INSTANCE = - new OrmOneToOneMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmOneToOneMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmOneToOneMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmOneToOneMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPackageChooser.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPackageChooser.java deleted file mode 100644 index 06a93c3aae..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPackageChooser.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.details.orm; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.widgets.PackageChooserPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | PackageChooserPane | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see EntityMappings - * @see EntityMappingsDetailsPage - The parent container - * @see PackageChooserPane - * - * @version 2.0 - * @since 2.0 - */ -public class OrmPackageChooser extends Pane<EntityMappings> -{ - /** - * Creates a new <code>XmlPackageChooser</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - public OrmPackageChooser(Pane<? extends EntityMappings> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - addPackageChooserPane(container); - } - - private void addPackageChooserPane(Composite container) { - - new PackageChooserPane<EntityMappings>(this, container) { - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<EntityMappings, String>(getSubjectHolder(), EntityMappings.PACKAGE_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getPackage(); - } - - @Override - protected void setValue_(String value) { - subject.setPackage(value == "" ? null : value); //$NON-NLS-1$ - } - }; - } - - @Override - protected String getLabelText() { - return JptUiDetailsOrmMessages.EntityMappingsDetailsPage_package; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected String getPackageName() { - return getSubject().getPackage(); - } - - @Override - protected void setPackageName(String packageName) { - getSubject().setPackage(packageName); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentAttributeDetailsPage.java deleted file mode 100644 index 144e10cde1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentAttributeDetailsPage.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.orm; - -import java.util.ArrayList; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.PersistentAttributeDetailsPage; -import org.eclipse.jpt.jpa.ui.internal.details.PersistentAttributeMapAsComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * The default implementation of the details page used for the XML persistent - * attribute. - * <p> - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | OrmPersistentAttributeMapAsComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | Attribute mapping pane | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OrmPersistentAttribute - * @see OrmPersistentAttributeMapAsComposite - * - * @version 2.3 - * @since 2.0 - */ -public class OrmPersistentAttributeDetailsPage - extends PersistentAttributeDetailsPage<OrmReadOnlyPersistentAttribute> -{ - /** - * Creates a new <code>OrmPersistentAttributeDetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmPersistentAttributeDetailsPage(Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - ArrayList<Pane<?>> panes = new ArrayList<Pane<?>>(2); - - // Map As composite - Pane<?> mapAsPane = buildMapAsPane(addSubPane(container, 0, 0, 5, 0)); - panes.add(mapAsPane); - - buildMappingPageBook(container); - - installPaneEnabler(panes); - } - - protected Pane<ReadOnlyPersistentAttribute> buildMapAsPane(Composite parent) { - return new PersistentAttributeMapAsComposite(this, parent); - } - - private void installPaneEnabler(ArrayList<Pane<?>> panes) { - new PaneEnabler(buildPaneEnablerHolder(), panes); - } - - private PropertyValueModel<Boolean> buildPaneEnablerHolder() { - return new TransformationPropertyValueModel<OrmReadOnlyPersistentAttribute, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform_(OrmReadOnlyPersistentAttribute value) { - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - - //TODO this probably needs to change and use a PaneEnabler instead. - @Override - protected JpaComposite getMappingComposite(String key) { - JpaComposite mappingComposite = super.getMappingComposite(key); - if (mappingComposite == null) { - return null; - } - boolean enabled = false; - - if (getSubject() != null && getSubject().getParent() != null) { - enabled = !getSubject().isVirtual(); - } - - mappingComposite.enableWidgets(enabled); - return mappingComposite; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentAttributeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentAttributeDetailsProvider.java deleted file mode 100644 index 9527d29496..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentAttributeDetailsProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmStructureNodes; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.swt.widgets.Composite; - -/** - * This provider is responsible for creating the {@link JpaDetailsPage} - * when the information comes from the XML file (either from the persistence - * configuration or from the Mappings Descriptor). - */ -public class OrmPersistentAttributeDetailsProvider - implements JpaDetailsProvider -{ - // singleton - private static final JpaDetailsProvider INSTANCE = new OrmPersistentAttributeDetailsProvider(); - - - /** - * Return the singleton - */ - public static JpaDetailsProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private OrmPersistentAttributeDetailsProvider() { - super(); - } - - - public boolean providesDetails(JpaStructureNode structureNode) { - return Tools.valuesAreEqual(structureNode.getId(), OrmStructureNodes.PERSISTENT_ATTRIBUTE_ID) - && structureNode.getResourceType().getContentType().isKindOf(JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE); - } - - public JpaDetailsPage<OrmReadOnlyPersistentAttribute> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new OrmPersistentAttributeDetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentTypeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentTypeDetailsProvider.java deleted file mode 100644 index 4dd48709d9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPersistentTypeDetailsProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmStructureNodes; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.PersistentTypeDetailsPage; -import org.eclipse.swt.widgets.Composite; - -/** - * This provider is responsible for creating the {@link JpaDetailsPage} - * when the information comes from the XML file (either from the persistence - * configuration or from the Mappings Descriptor). - */ -public class OrmPersistentTypeDetailsProvider - implements JpaDetailsProvider -{ - // singleton - private static final JpaDetailsProvider INSTANCE = new OrmPersistentTypeDetailsProvider(); - - - /** - * Return the singleton - */ - public static JpaDetailsProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private OrmPersistentTypeDetailsProvider() { - super(); - } - - - public boolean providesDetails(JpaStructureNode structureNode) { - return Tools.valuesAreEqual(structureNode.getId(), OrmStructureNodes.PERSISTENT_TYPE_ID) - && structureNode.getResourceType().getContentType().isKindOf(JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE); - } - - public JpaDetailsPage<PersistentType> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new PersistentTypeDetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java deleted file mode 100644 index 2769853208..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.details.orm; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractPrimaryKeyJoinColumnsComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * @see OrmEntity - * @see OrmInheritanceComposite - The container of this pane - * - * @version 2.0 - * @since 2.0 - */ -public class OrmPrimaryKeyJoinColumnsComposite extends AbstractPrimaryKeyJoinColumnsComposite<OrmEntity> -{ - public OrmPrimaryKeyJoinColumnsComposite(Pane<? extends OrmEntity> subjectHolder, - Composite parent) { - - super(subjectHolder, parent); - } - - @Override - protected ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildDefaultJoinColumnsListHolder() { - return new ListAspectAdapter<OrmEntity, ReadOnlyPrimaryKeyJoinColumn>( - getSubjectHolder(), - OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST) - { - @Override - protected ListIterator<ReadOnlyPrimaryKeyJoinColumn> listIterator_() { - return subject.defaultPrimaryKeyJoinColumns(); - } -//TODO defaultPrimaryKeyJoinColumnsSize when I can change the API -// @Override -// protected int size_() { -// return subject.defaultPrimaryKeyJoinColumnsSize(); -// } - }; - } - - @Override - protected void switchDefaultToSpecified() { - ListIterator<ReadOnlyPrimaryKeyJoinColumn> defaultJoinColumns = getSubject().defaultPrimaryKeyJoinColumns(); - - while (defaultJoinColumns.hasNext()) { - ReadOnlyPrimaryKeyJoinColumn defaultJoinColumn = defaultJoinColumns.next(); - String columnName = defaultJoinColumn.getName(); - String referencedColumnName = defaultJoinColumn.getReferencedColumnName(); - - PrimaryKeyJoinColumn pkJoinColumn = getSubject().addSpecifiedPrimaryKeyJoinColumn(); - pkJoinColumn.setSpecifiedName(columnName); - pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName); - } - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmQueriesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmQueriesComposite.java deleted file mode 100644 index 98d6dbb72a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmQueriesComposite.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.internal.details.QueriesComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | QueriesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EntityMappings - * @see EntityMappingsDetailsPage - The parent container - * @see QueriesComposite - * - * @version 2.0 - * @since 2.0 - */ -public class OrmQueriesComposite extends Pane<EntityMappings> { - - /** - * Creates a new <code>OrmQueriesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OrmQueriesComposite(Pane<? extends EntityMappings> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - private PropertyValueModel<Boolean> buildPaneEnablerHolder() { - return new TransformationPropertyValueModel<EntityMappings, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(EntityMappings value) { - return (value != null); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - container = this.addCollapsibleSection( - container, - JptUiDetailsOrmMessages.OrmQueriesComposite_groupBox - ); - - QueriesComposite queriesComposite = this.buildQueriesComposite(container, this.buildQueryContainerHolder()); - - this.installPaneEnabler(queriesComposite); - } - - protected QueriesComposite buildQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) { - return new QueriesComposite(this, queryContainerHolder, container); - } - - private PropertyValueModel<QueryContainer> buildQueryContainerHolder() { - return new PropertyAspectAdapter<EntityMappings, QueryContainer>(getSubjectHolder()) { - @Override - protected QueryContainer buildValue_() { - return this.subject.getQueryContainer(); - } - }; - } - private void installPaneEnabler(QueriesComposite queriesComposite) { - new PaneEnabler( - buildPaneEnablerHolder(), - queriesComposite - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmSecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmSecondaryTablesComposite.java deleted file mode 100644 index 397ab90092..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmSecondaryTablesComposite.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.ReadOnlySecondaryTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.SecondaryTable; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmSecondaryTable; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualSecondaryTable; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractSecondaryTablesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.PrimaryKeyJoinColumnsInSecondaryTableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.SecondaryTableDialog; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PrimaryKeyJoinColumnsInSecondaryTableComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see OrmEntity - * @see OrmEntityComposite - The container of this pane - * @see AddRemoveListPane - * @see PrimaryKeyJoinColumnsInSecondaryTableComposite - * - * @version 2.0 - * @since 1.0 - */ -public class OrmSecondaryTablesComposite extends AbstractSecondaryTablesComposite<OrmEntity> -{ - /** - * Creates a new <code>OrmSecondaryTablesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OrmSecondaryTablesComposite(Pane<? extends OrmEntity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Creates a new <code>SecondaryTablesComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmSecondaryTablesComposite(PropertyValueModel<? extends OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - private WritablePropertyValueModel<Boolean> buildDefineInXmlHolder() { - return new DefineInXmlHolder(); - } - - private ListValueModel<ReadOnlySecondaryTable> buildSecondaryTablesListHolder() { - List<ListValueModel<? extends ReadOnlySecondaryTable>> list = new ArrayList<ListValueModel<? extends ReadOnlySecondaryTable>>(); - list.add(buildSpecifiedSecondaryTablesListHolder()); - list.add(buildVirtualSecondaryTablesListHolder()); - return new CompositeListValueModel<ListValueModel<? extends ReadOnlySecondaryTable>, ReadOnlySecondaryTable>(list); - } - - private ListValueModel<ReadOnlySecondaryTable> buildSecondaryTablesListModel() { - return new ItemPropertyListValueModelAdapter<ReadOnlySecondaryTable>(buildSecondaryTablesListHolder(), - ReadOnlyTable.SPECIFIED_NAME_PROPERTY); - } - - private ListValueModel<OrmSecondaryTable> buildSpecifiedSecondaryTablesListHolder() { - return new ListAspectAdapter<OrmEntity, OrmSecondaryTable>(getSubjectHolder(), Entity.SPECIFIED_SECONDARY_TABLES_LIST) { - @Override - protected ListIterator<OrmSecondaryTable> listIterator_() { - return subject.specifiedSecondaryTables(); - } - - @Override - protected int size_() { - return subject.specifiedSecondaryTablesSize(); - } - }; - } - - ListValueModel<OrmVirtualSecondaryTable> buildVirtualSecondaryTablesListHolder() { - return new ListAspectAdapter<OrmEntity, OrmVirtualSecondaryTable>(getSubjectHolder(), OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST) { - @Override - protected ListIterator<OrmVirtualSecondaryTable> listIterator_() { - return this.subject.virtualSecondaryTables(); - } - - @Override - protected int size_() { - return subject.virtualSecondaryTablesSize(); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = getGroupBoxMargin(); - - WritablePropertyValueModel<SecondaryTable> secondaryTableHolder = - buildSecondaryTableHolder(); - - WritablePropertyValueModel<Boolean> defineInXmlHolder = - buildDefineInXmlHolder(); - - // Override Define In XML check box - addCheckBox( - addSubPane(container, 0, groupBoxMargin), - JptUiDetailsMessages.OrmSecondaryTablesComposite_defineInXml, - defineInXmlHolder, - null - ); - - // Secondary Tables add/remove list pane - AddRemoveListPane<Entity> listPane = new AddRemoveListPane<Entity>( - this, - addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin), - buildSecondaryTablesAdapter(), - buildSecondaryTablesListModel(), - secondaryTableHolder, - buildSecondaryTableLabelProvider(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS//TODO need a help context id for this - ); - - installListPaneEnabler(defineInXmlHolder, listPane); - - // Primary Key Join Columns pane - new PrimaryKeyJoinColumnsInSecondaryTableComposite( - this, - secondaryTableHolder, - container - ); - } - - private void installListPaneEnabler(WritablePropertyValueModel<Boolean> defineInXmlHolder, - AddRemoveListPane<Entity> listPane) { - - new PaneEnabler(defineInXmlHolder, listPane); - } - - @Override - protected SecondaryTableDialog buildSecondaryTableDialogForAdd() { - // defaultSchema and defaultCatalog should not be taken from the Table in this case. - // The table default schema could be what is the specified schema on the java table. - return new SecondaryTableDialog( - getShell(), getSubject().getJpaProject(), - getSubject().getMappingFileRoot().getCatalog(), - getSubject().getMappingFileRoot().getSchema()); - } - - private class DefineInXmlHolder extends ListPropertyValueModelAdapter<Boolean> - implements WritablePropertyValueModel<Boolean> { - - public DefineInXmlHolder() { - super(buildVirtualSecondaryTablesListHolder()); - } - - @Override - protected Boolean buildValue() { - if (getSubject() == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(getSubject().secondaryTablesAreDefinedInXml()); - } - - public void setValue(Boolean value) { - getSubject().setSecondaryTablesAreDefinedInXml(value.booleanValue()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmTransientMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmTransientMappingUiDefinition.java deleted file mode 100644 index de38367117..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmTransientMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractTransientMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmTransientMappingUiDefinition - extends AbstractTransientMappingUiDefinition<ReadOnlyPersistentAttribute, OrmTransientMapping> - implements OrmAttributeMappingUiDefinition<OrmTransientMapping> -{ - // singleton - private static final OrmTransientMappingUiDefinition INSTANCE = - new OrmTransientMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmTransientMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmTransientMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmTransientMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmVersionMappingComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmVersionMappingComposite.java deleted file mode 100644 index af5bb381d1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmVersionMappingComposite.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.VersionMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractVersionMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmVersionMappingComposite - extends AbstractVersionMappingComposite<VersionMapping> -{ - /** - * Creates a new <code>EclipseLinkOrmVersionMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>VersionMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmVersionMappingComposite(PropertyValueModel<? extends VersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeVersionSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmVersionMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmVersionMappingUiDefinition.java deleted file mode 100644 index de8d9b3207..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmVersionMappingUiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractVersionMappingUiDefinition; -import org.eclipse.swt.widgets.Composite; - -public class OrmVersionMappingUiDefinition - extends AbstractVersionMappingUiDefinition<ReadOnlyPersistentAttribute, OrmVersionMapping> - implements OrmAttributeMappingUiDefinition<OrmVersionMapping> -{ - // singleton - private static final OrmVersionMappingUiDefinition INSTANCE = - new OrmVersionMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmVersionMapping> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmVersionMappingUiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return factory.createOrmVersionMappingComposite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmXmlUiDefinition.java deleted file mode 100644 index f2758cb785..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmXmlUiDefinition.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.details.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.structure.OrmResourceModelStructureProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class OrmXmlUiDefinition extends AbstractOrmXmlResourceUiDefinition -{ - // singleton - private static final ResourceUiDefinition INSTANCE = new OrmXmlUiDefinition(); - - - /** - * Return the singleton - */ - public static ResourceUiDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private OrmXmlUiDefinition() { - super(); - } - - - @Override - protected OrmXmlUiFactory buildOrmXmlUiFactory() { - return new GenericOrmXmlUiFactory(); - } - - public boolean providesUi(JptResourceType resourceType) { - return resourceType.equals(JptJpaCorePlugin.ORM_XML_1_0_RESOURCE_TYPE); - } - - public JpaStructureProvider getStructureProvider() { - return OrmResourceModelStructureProvider.instance(); - } - - @Override - protected void addOrmAttributeMappingUiDefinitionsTo( - List<OrmAttributeMappingUiDefinition<? extends AttributeMapping>> definitions) { - - definitions.add(OrmIdMappingUiDefinition.instance()); - definitions.add(OrmEmbeddedIdMappingUiDefinition.instance()); - definitions.add(OrmBasicMappingUiDefinition.instance()); - definitions.add(OrmVersionMappingUiDefinition.instance()); - definitions.add(OrmManyToOneMappingUiDefinition.instance()); - definitions.add(OrmOneToManyMappingUiDefinition.instance()); - definitions.add(OrmOneToOneMappingUiDefinition.instance()); - definitions.add(OrmManyToManyMappingUiDefinition.instance()); - definitions.add(OrmEmbeddedMappingUiDefinition.instance()); - definitions.add(OrmTransientMappingUiDefinition.instance()); - } - - @Override - protected void addOrmTypeMappingUiDefinitionsTo( - List<OrmTypeMappingUiDefinition<? extends TypeMapping>> definitions) { - - definitions.add(OrmEntityUiDefinition.instance()); - definitions.add(OrmMappedSuperclassUiDefinition.instance()); - definitions.add(OrmEmbeddableUiDefinition.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/PersistenceUnitMetadataComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/PersistenceUnitMetadataComposite.java deleted file mode 100644 index cd52166754..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/PersistenceUnitMetadataComposite.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.details.orm; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitDefaults; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistenceUnitDefaults2_0; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.jpa.ui.internal.jpa2.Jpa2_0ProjectFlagModel; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - Persistence Unit ------------------------------------------------------ | - * | | - * | x XML Mapping Metadata Complete | - * | | - * | x Cascade Persist | - * | | - * | ------------------------------------------------------------ | - * | Schema: | SchemaCombo | | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Catalog: | CatalogCombo | | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Access Type: | |v| | - * | ------------------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnitMetadata - * @see OrmPersistenceUnitDefaults - * @see EntityMappingsDetailsPage - The parent container - * @see CatalogCombo - * @see SchemaCombo - * @see EnumFormComboViewer - * - * @version 2.0 - * @since 2.0 - */ -public class PersistenceUnitMetadataComposite extends Pane<OrmPersistenceUnitMetadata> -{ - /** - * Creates a new <code>PersistenceUnitMetadataComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public PersistenceUnitMetadataComposite(Pane<?> parentPane, - PropertyValueModel<? extends OrmPersistenceUnitMetadata> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - private EnumFormComboViewer<OrmPersistenceUnitDefaults, AccessType> addAccessTypeCombo(Composite container) { - - return new EnumFormComboViewer<OrmPersistenceUnitDefaults, AccessType>(this, buildPersistenceUnitDefaultsHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(OrmPersistenceUnitDefaults.ACCESS_PROPERTY); - } - - @Override - protected AccessType[] getChoices() { - return AccessType.values(); - } - - @Override - protected AccessType getDefaultValue() { - return null; - } - - @Override - protected String displayString(AccessType value) { - return buildDisplayString( - JptUiDetailsOrmMessages.class, - PersistenceUnitMetadataComposite.this, - value - ); - } - - @Override - protected AccessType getValue() { - return getSubject().getAccess(); - } - - @Override - protected void setValue(AccessType value) { - getSubject().setAccess(value); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildCascadePersistHolder() { - return new PropertyAspectAdapter<OrmPersistenceUnitDefaults, Boolean>(buildPersistenceUnitDefaultsHolder(), OrmPersistenceUnitDefaults.CASCADE_PERSIST_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isCascadePersist()); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setCascadePersist(value.booleanValue()); - } - }; - } - - private CatalogCombo<OrmPersistenceUnitDefaults> addCatalogCombo(Composite container) { - - return new CatalogCombo<OrmPersistenceUnitDefaults>(this, buildPersistenceUnitDefaultsHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(OrmPersistenceUnitDefaults.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(OrmPersistenceUnitDefaults.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultCatalog(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedCatalog(); - } - }; - } - - private PropertyValueModel<OrmPersistenceUnitDefaults> buildPersistenceUnitDefaultsHolder() { - return new TransformationPropertyValueModel<OrmPersistenceUnitMetadata, OrmPersistenceUnitDefaults>(getSubjectHolder()) { - @Override - protected OrmPersistenceUnitDefaults transform_(OrmPersistenceUnitMetadata value) { - return value.getPersistenceUnitDefaults(); - } - }; - } - - private SchemaCombo<OrmPersistenceUnitDefaults> addSchemaCombo(Composite container) { - - return new SchemaCombo<OrmPersistenceUnitDefaults>(this, buildPersistenceUnitDefaultsHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(OrmPersistenceUnitDefaults.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(OrmPersistenceUnitDefaults.SPECIFIED_SCHEMA_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultSchema(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - return this.getSubject().getDbSchemaContainer(); - } - - }; - } - - private WritablePropertyValueModel<Boolean> buildXmlMappingMetadataCompleteHolder() { - return new PropertyAspectAdapter<OrmPersistenceUnitMetadata, Boolean>(getSubjectHolder(), OrmPersistenceUnitMetadata.XML_MAPPING_METADATA_COMPLETE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isXmlMappingMetadataComplete()); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setXmlMappingMetadataComplete(value.booleanValue()); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildDelimitedIdentifiersHolder() { - return new PropertyAspectAdapter<OrmPersistenceUnitDefaults, Boolean>(buildPersistenceUnitDefaultsHolder(), OrmPersistenceUnitDefaults2_0.DELIMITED_IDENTIFIERS_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.buildBooleanValue_()); - } - - protected boolean buildBooleanValue_() { - return JptJpaCorePlugin.nodeIsJpa2_0Compatible(this.subject) && - ((OrmPersistenceUnitDefaults2_0) this.subject).isDelimitedIdentifiers(); - } - - @Override - protected void setValue_(Boolean value) { - if (JptJpaCorePlugin.nodeIsJpa2_0Compatible(this.subject)) { - ((OrmPersistenceUnitDefaults2_0) this.subject).setDelimitedIdentifiers(value.booleanValue()); - } - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - // Section - container = addCollapsibleSection( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_persistenceUnitSection - ); - - // XML mapping metadata complete check box - addCheckBox( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_xmlMappingMetadataCompleteCheckBox, - buildXmlMappingMetadataCompleteHolder(), - JpaHelpContextIds.ENTITY_ORM_XML - ); - - // Cascade Persist check-box - addCheckBox( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_cascadePersistCheckBox, - buildCascadePersistHolder(), - JpaHelpContextIds.ENTITY_ORM_CASCADE - ); - - // Schema widgets - addLabeledComposite( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_schema, - addSchemaCombo(container), - JpaHelpContextIds.ENTITY_ORM_SCHEMA - ); - - // Catalog widgets - addLabeledComposite( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_catalog, - addCatalogCombo(container), - JpaHelpContextIds.ENTITY_ORM_CATALOG - ); - - // Access Type widgets - addLabeledComposite( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_access, - addAccessTypeCombo(container), - JpaHelpContextIds.ENTITY_ORM_ACCESS - ); - - // Delimited Identifiers check-box - Button diCheckBox = this.addCheckBox( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_delimitedIdentifiersCheckBox, - this.buildDelimitedIdentifiersHolder(), - JpaHelpContextIds.ENTITY_ORM_DELIMITED_IDENTIFIERS - ); - - SWTTools.controlVisibleState(new Jpa2_0ProjectFlagModel<OrmPersistenceUnitMetadata>(this.getSubjectHolder()), diCheckBox); - - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/UnsupportedOrmMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/UnsupportedOrmMappingUiDefinition.java deleted file mode 100644 index d4a0f788e0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/UnsupportedOrmMappingUiDefinition.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappingUiDefinition; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class UnsupportedOrmMappingUiDefinition - extends AbstractMappingUiDefinition - implements OrmAttributeMappingUiDefinition -{ - // singleton - private static final UnsupportedOrmMappingUiDefinition INSTANCE = - new UnsupportedOrmMappingUiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private UnsupportedOrmMappingUiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsOrmMessages.UnsupportedOrmMappingUiProvider_label; - } - - public String getLinkLabel() { - return JptUiDetailsOrmMessages.UnsupportedOrmMappingUiProvider_linkLabel; - } - - public String getKey() { - return null; - } - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return new NullComposite(subjectHolder, parent, widgetFactory); - } - - public static class NullComposite extends Pane<JavaAttributeMapping> - implements JpaComposite - { - NullComposite( - PropertyValueModel<JavaAttributeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) {} - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentAttributeToXmlAndMapDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentAttributeToXmlAndMapDialog.java deleted file mode 100644 index b35e5c58e7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentAttributeToXmlAndMapDialog.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.dialogs; - -import java.util.Comparator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.StatusDialog; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import com.ibm.icu.text.Collator; - -public class AddPersistentAttributeToXmlAndMapDialog extends StatusDialog -{ - private OrmReadOnlyPersistentAttribute unmappedPersistentAttribute; - private Text attributeText; - private ComboViewer mappingCombo; - - public AddPersistentAttributeToXmlAndMapDialog(Shell parentShell, OrmReadOnlyPersistentAttribute unmappedPersistentAttribute) { - super(parentShell); - this.unmappedPersistentAttribute = unmappedPersistentAttribute; - setTitle(JptUiMessages.AddPersistentAttributeDialog_title); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite dialogArea = (Composite) super.createDialogArea(parent); - - Composite composite = new Composite(dialogArea, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setLayout(new GridLayout()); - - createLabel(composite, 1, JptUiMessages.AddPersistentAttributeDialog_attributeLabel); - - attributeText = createText(composite, 1); -// attributeText.addModifyListener( -// new ModifyListener() { -// public void modifyText(ModifyEvent e) { -// validate(); -// } -// } -// ); - attributeText.setText(unmappedPersistentAttribute.getName()); - attributeText.setEditable(false); - - createLabel(composite, 1, JptUiMessages.AddPersistentClassDialog_mappingLabel); - - mappingCombo = new ComboViewer(createCombo(composite, 1)); - mappingCombo.getCombo().setFocus(); - mappingCombo.setContentProvider( - new IStructuredContentProvider() { - public void dispose() {} - - public Object[] getElements(Object inputElement) { - return ArrayTools.array( - CollectionTools.sort( - new FilteringIterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ?>>( - ((JpaPlatformUi) inputElement).attributeMappingUiDefinitions(unmappedPersistentAttribute.getResourceType())) { - @Override - protected boolean accept(MappingUiDefinition<ReadOnlyPersistentAttribute, ?> o) { - return o.isEnabledFor(AddPersistentAttributeToXmlAndMapDialog.this.unmappedPersistentAttribute); - } - }, - getProvidersComparator())); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} - }); - mappingCombo.setLabelProvider( - new LabelProvider() { - @Override - public String getText(Object element) { - return ((MappingUiDefinition) element).getLabel(); - } - }); - mappingCombo.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - validate(); - } - }); - JpaPlatformUi jpaPlatformUi = JptJpaUiPlugin.instance().getJpaPlatformUi(this.unmappedPersistentAttribute.getJpaProject().getJpaPlatform()); - mappingCombo.setInput(jpaPlatformUi); - mappingCombo.getCombo().select(0); // select Basic to begin - - // TODO - F1 Help - // PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IDaliHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_DATABASE); - - //getButton(IDialogConstants.OK_ID).setEnabled(false); // disabled to start - applyDialogFont(dialogArea); - - validate(); - - return dialogArea; - } - - protected Comparator<MappingUiDefinition> getProvidersComparator() { - return new Comparator<MappingUiDefinition>() { - public int compare(MappingUiDefinition item1, MappingUiDefinition item2) { - String displayString1 = item1.getLabel(); - String displayString2 = item2.getLabel(); - return Collator.getInstance().compare(displayString1, displayString2); - } - }; - } - - private Label createLabel(Composite container, int span, String text) { - Label label = new Label(container, SWT.NONE); - label.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - label.setLayoutData(gd); - return label; - } - - private Text createText(Composite container, int span) { - Text text = new Text(container, SWT.BORDER | SWT.SINGLE); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = span; - gd.widthHint = 250; - text.setLayoutData(gd); - return text; - } - - private Combo createCombo(Composite container, int span) { - Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = span; - combo.setLayoutData(gd); - return combo; - } - - public String getAttributeName() { - return attributeText.getText(); - } - - public String getMappingKey() { - StructuredSelection selection = (StructuredSelection) mappingCombo.getSelection(); - return (selection.isEmpty()) ? null : ((MappingUiDefinition) selection.getFirstElement()).getKey(); - } - - private void validate() { -// if (entityMappings.containsPersistentType(type)) { -// updateStatus( -// new Status( -// IStatus.WARNING, JptJpaUiPlugin.PLUGIN_ID, -// JptUiMessages.AddPersistentClassDialog_duplicateClassWarning)); -// return; -// } -// - String mappingKey = getMappingKey(); - if (mappingKey == null) { - updateStatus( - new Status( - IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, - JptUiMessages.AddPersistentAttributeDialog_noMappingKeyError)); - return; - } - - updateStatus(Status.OK_STATUS); - } - - @Override - protected void okPressed() { - unmappedPersistentAttribute.convertToSpecified(getMappingKey()); - super.okPressed(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java deleted file mode 100644 index aa8ea3ab21..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.dialogs; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper; -import org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor; -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.StatusDialog; -import org.eclipse.jface.fieldassist.FieldDecorationRegistry; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEmbeddableUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEntityUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappedSuperclassUiDefinition; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.ui.progress.IProgressService; - -public class AddPersistentClassDialog extends StatusDialog -{ - private EntityMappings entityMappings; - - private Text classText; - - private Button classBrowseButton; - - private ComboViewer mappingCombo; - - private OrmPersistentType addedType; - - - public AddPersistentClassDialog(Shell parentShell, EntityMappings entityMappings) { - super(parentShell); - this.entityMappings = entityMappings; - setTitle(JptUiMessages.AddPersistentClassDialog_title); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite dialogArea = (Composite) super.createDialogArea(parent); - - Composite composite = new Composite(dialogArea, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setLayout(new GridLayout(3, false)); - - createLabel(composite, JptUiMessages.AddPersistentClassDialog_classLabel); - - this.classText = createText(composite); - this.classText.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - validate(); - } - } - ); - - this.classBrowseButton = createButton(composite, JptUiMessages.General_browse); - this.classBrowseButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - IType type = chooseType(); - if (type != null) { - classText.setText(type.getFullyQualifiedName('$')); - } - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - createLabel(composite, JptUiMessages.AddPersistentClassDialog_mappingLabel); - - this.mappingCombo = new ComboViewer(createCombo(composite, 2)); - this.mappingCombo.setContentProvider( - new IStructuredContentProvider() { - public void dispose() {} - - public Object[] getElements(Object inputElement) { - return new Object[] { - OrmMappedSuperclassUiDefinition.instance(), - OrmEntityUiDefinition.instance(), - OrmEmbeddableUiDefinition.instance() - }; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} - }); - this.mappingCombo.setLabelProvider( - new LabelProvider() { - @Override - public String getText(Object element) { - return ((MappingUiDefinition) element).getLabel(); - } - }); - this.mappingCombo.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - validate(); - } - }); - this.mappingCombo.setInput("FOO"); - this.mappingCombo.getCombo().select(1); // select Entity to begin - - // TODO - F1 Help - // PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IDaliHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_DATABASE); - - //getButton(IDialogConstants.OK_ID).setEnabled(false); // disabled to start - applyDialogFont(dialogArea); - - validate(); - - return dialogArea; - } - - private Label createLabel(Composite container, String text) { - Label label = new Label(container, SWT.NONE); - label.setText(text); - return label; - } - - private Text createText(Composite container) { - // TODO bug 156185 - when this is fixed there should be api for this - JavaTypeCompletionProcessor javaTypeCompletionProcessor = new JavaTypeCompletionProcessor(false, false); - IPackageFragmentRoot pfr = getPackageFragmentRoot(); - if (pfr != null) { - javaTypeCompletionProcessor.setPackageFragment(pfr.getPackageFragment("")); - } - - Text text = new Text(container, SWT.BORDER | SWT.SINGLE); - - ControlContentAssistHelper.createTextContentAssistant( - text, - javaTypeCompletionProcessor - ); - - text.setLayoutData(getFieldGridData()); - return text; - } - - protected GridData getFieldGridData() { - int margin = FieldDecorationRegistry.getDefault() - .getMaximumDecorationWidth(); - GridData data = new GridData(); - data.horizontalAlignment = SWT.FILL; - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + margin; - data.horizontalIndent = margin; - data.grabExcessHorizontalSpace = true; - return data; - } - - protected IPackageFragmentRoot getPackageFragmentRoot() { - return JDTTools.getCodeCompletionContextRoot(getJpaProject().getJavaProject()); - } - - - private Button createButton(Composite container, String text) { - Button button = new Button(container, SWT.NONE); - button.setText(text); - return button; - } - - private Combo createCombo(Composite container, int span) { - Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); - GridData gd = getFieldGridData(); - gd.horizontalSpan = span; - combo.setLayoutData(gd); - return combo; - } - - private JpaProject getJpaProject() { - return this.entityMappings.getJpaProject(); - } - - public String getClassName() { - return this.classText.getText(); - } - - public String getMappingKey() { - StructuredSelection selection = (StructuredSelection) this.mappingCombo.getSelection(); - return (selection.isEmpty()) ? null : ((MappingUiDefinition) selection.getFirstElement()).getKey(); - } - - protected IType chooseType() { - IJavaElement[] elements= new IJavaElement[] { getJpaProject().getJavaProject() }; - IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - - SelectionDialog typeSelectionDialog; - try { - typeSelectionDialog = - JavaUI.createTypeDialog( - getShell(), service, scope, - IJavaElementSearchConstants.CONSIDER_CLASSES, - false, getClassName()); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - throw new RuntimeException(e); - } - typeSelectionDialog.setTitle(JptUiMessages.AddPersistentClassDialog_classDialog_title); - typeSelectionDialog.setMessage(JptUiMessages.AddPersistentClassDialog_classDialog_message); - - if (typeSelectionDialog.open() == Window.OK) { - return (IType) typeSelectionDialog.getResult()[0]; - } - return null; - } - - private void validate() { - String className = getClassName(); - - if (StringTools.stringIsEmpty(className)) { - updateStatus( - new Status( - IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, - JptUiMessages.AddPersistentClassDialog_noClassError)); - return; - } - className = className.replace('$', '.'); - - IType type; - try { - type = getJpaProject().getJavaProject().findType(className); - } - catch (JavaModelException jme) { - type = null; - } - - if (type == null) { - updateStatus( - new Status( - IStatus.WARNING, JptJpaUiPlugin.PLUGIN_ID, - JptUiMessages.AddPersistentClassDialog_classNotFoundWarning)); - return; - } - - if (this.entityMappings.containsPersistentType(className)) { - updateStatus( - new Status( - IStatus.WARNING, JptJpaUiPlugin.PLUGIN_ID, - JptUiMessages.AddPersistentClassDialog_duplicateClassWarning)); - return; - } - - String mappingKey = getMappingKey(); - if (mappingKey == null) { - updateStatus( - new Status( - IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, - JptUiMessages.AddPersistentClassDialog_noMappingKeyError)); - return; - } - - updateStatus(Status.OK_STATUS); - } - - @Override - protected void okPressed() { - this.addedType = this.entityMappings.addPersistentType(getMappingKey(), getClassName()); - super.okPressed(); - } - - public OrmPersistentType openAndReturnType() { - super.open(); - return addedType; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceContributor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceContributor.java deleted file mode 100644 index 4b2661a898..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceContributor.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.editors; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.ide.IDEActionFactory; -import org.eclipse.ui.part.MultiPageEditorActionBarContributor; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; - -/** - * - * @version 2.0 - * @since 2.0 - */ -public class PersistenceContributor extends MultiPageEditorActionBarContributor { - - private IEditorPart activeEditorPart; - - /** - * Creates a new <code>PersistenceContributor</code>. - */ - public PersistenceContributor() { - super(); - } - - /* - * (non-Javadoc) - */ - @Override - public void contributeToMenu(IMenuManager manager) { - } - - /* - * (non-Javadoc) - */ - @Override - public void contributeToToolBar(IToolBarManager manager) { - } - - /** - * Returns the action registed with the given text editor. - * @return IAction or null if editor is null. - */ - protected IAction getAction(ITextEditor editor, String actionID) { - return (editor == null ? null : editor.getAction(actionID)); - } - - /* - * (non-Javadoc) - */ - @Override - public void setActivePage(IEditorPart part) { - - if (activeEditorPart == part) - return; - - activeEditorPart = part; - - IActionBars actionBars = getActionBars(); - if (actionBars != null) { - - ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; - - actionBars.setGlobalActionHandler( - ActionFactory.DELETE.getId(), - getAction(editor, ITextEditorActionConstants.DELETE)); - actionBars.setGlobalActionHandler( - ActionFactory.UNDO.getId(), - getAction(editor, ITextEditorActionConstants.UNDO)); - actionBars.setGlobalActionHandler( - ActionFactory.REDO.getId(), - getAction(editor, ITextEditorActionConstants.REDO)); - actionBars.setGlobalActionHandler( - ActionFactory.CUT.getId(), - getAction(editor, ITextEditorActionConstants.CUT)); - actionBars.setGlobalActionHandler( - ActionFactory.COPY.getId(), - getAction(editor, ITextEditorActionConstants.COPY)); - actionBars.setGlobalActionHandler( - ActionFactory.PASTE.getId(), - getAction(editor, ITextEditorActionConstants.PASTE)); - actionBars.setGlobalActionHandler( - ActionFactory.SELECT_ALL.getId(), - getAction(editor, ITextEditorActionConstants.SELECT_ALL)); - actionBars.setGlobalActionHandler( - ActionFactory.FIND.getId(), - getAction(editor, ITextEditorActionConstants.FIND)); - actionBars.setGlobalActionHandler( - IDEActionFactory.BOOKMARK.getId(), - getAction(editor, IDEActionFactory.BOOKMARK.getId())); - actionBars.updateActionBars(); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java deleted file mode 100644 index 4e9418bbf1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java +++ /dev/null @@ -1,436 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.editors; - -import java.util.ListIterator; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.resource.LocalResourceManager; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.FormWidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.PersistenceXmlResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormEditor; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.TableWrapData; -import org.eclipse.ui.forms.widgets.TableWrapLayout; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.sse.ui.StructuredTextEditor; - -/** - * This is the editor for the JPA Persistence Configuration (persistence.xml). - * The pages shown before the XML source editor are retrieved from the - * <code>JpaUiFactory</code>. - * - * @see JpaUiFactory - * - * @version 2.3 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class PersistenceEditor extends FormEditor -{ - /** - * The XML text editor. - */ - private StructuredTextEditor editor; - - /** - * The root of the holders used to retrieve the persistence unit and be - * notified when it changes. - */ - private WritablePropertyValueModel<IFileEditorInput> editorInputHolder; - - /** - * The factory used to create the various widgets. - */ - private WidgetFactory widgetFactory; - - private final ResourceManager resourceManager; - - /** - * Creates a new <code>PersistenceEditor</code>. - */ - public PersistenceEditor() { - super(); - this.resourceManager = new LocalResourceManager(JFaceResources.getResources()); - initialize(); - } - - @Override - @SuppressWarnings("unchecked") - public Object getAdapter(Class adapterClass) { - Object adapter = super.getAdapter(adapterClass); - if (adapter == null) { - adapter = editor.getAdapter(adapterClass); - } - return adapter; - } - - /** - * {@inheritDoc} - */ - @Override - protected void addPages() { - addPersistenceUnitPages(); - addXMLEditorPage(); - } - - /** - * Adds the pages that show the properties of the persistence configuration - * or its persistence units. - */ - private void addPersistenceUnitPages() { - - JpaProject jpaProject = getJpaProject(); - - // The project doesn't have JPA - if (jpaProject == null) { - return; - } - - PersistenceXml persistenceXml = jpaProject.getRootContextNode().getPersistenceXml(); - if (persistenceXml == null) { - return; - } - JptResourceType resourceType = persistenceXml.getResourceType(); - if (resourceType == null) { - return; // might not ever get here... (if we have a p.xml, it probably has a resource type...) - } - String platformId = jpaProject.getJpaPlatform().getId(); - JpaPlatformUi jpaPlatformUI = JpaPlatformUiRegistry.instance().getJpaPlatformUi(platformId); - PersistenceXmlResourceUiDefinition definition = - (PersistenceXmlResourceUiDefinition) jpaPlatformUI.getResourceUiDefinition(resourceType); - - ListIterator<JpaPageComposite> pages = definition.buildPersistenceUnitComposites( - buildPersistenceUnitHolder(), - getContainer(), - this.widgetFactory - ); - - while (pages.hasNext()) { - JpaPageComposite page = pages.next(); - - try { - FormPage formPage = new Page(page); - addPage(formPage); - } - catch (PartInitException e) { - // TODO - } - } - } - - /** - * Adds the page containing the XML editor. - */ - private void addXMLEditorPage() { - try { - editor = new StructuredTextEditor(); - editor.setEditorPart(this); - int index = addPage(editor, getEditorInput()); - setPageText(index, JptUiPersistenceMessages.PersistenceEditor_sourceTab); - } - catch (PartInitException e) { - // TODO - } - } - - private WritablePropertyValueModel<IFileEditorInput> buildEditorInputHolder() { - return new SimplePropertyValueModel<IFileEditorInput>(); - } - - private PropertyValueModel<JpaProject> buildJpaProjectHolder() { - return new CachingTransformationPropertyValueModel<IFileEditorInput, JpaProject>(this.editorInputHolder) { - @Override - protected JpaProject transform_(IFileEditorInput fileEditorInput) { - return JptJpaCorePlugin.getJpaProject(fileEditorInput.getFile().getProject()); - } - }; - } - - private PropertyValueModel<Persistence> buildPersistenceHolder() { - return new PropertyAspectAdapter<PersistenceXml, Persistence>(buildPersistenceXmlHolder(), PersistenceXml.PERSISTENCE_PROPERTY) { - @Override - protected Persistence buildValue_() { - return subject.getPersistence(); - } - }; - } - - private PropertyValueModel<PersistenceUnit> buildPersistenceUnitHolder() { - return new ListPropertyValueModelAdapter<PersistenceUnit>(buildPersistenceUnitListHolder()) { - @Override - protected PersistenceUnit buildValue() { - return listHolder.size() > 0 ? (PersistenceUnit) listHolder.get(0) : null; - } - }; - } - - private ListValueModel<PersistenceUnit> buildPersistenceUnitListHolder() { - return new ListAspectAdapter<Persistence, PersistenceUnit>(buildPersistenceHolder(), Persistence.PERSISTENCE_UNITS_LIST) { - @Override - protected ListIterator<PersistenceUnit> listIterator_() { - return subject.persistenceUnits(); - } - - @Override - protected int size_() { - return subject.persistenceUnitsSize(); - } - }; - } - - private PropertyValueModel<PersistenceXml> buildPersistenceXmlHolder() { - return new PropertyAspectAdapter<JpaRootContextNode, PersistenceXml>(buildRootContextNodeHolder(), JpaRootContextNode.PERSISTENCE_XML_PROPERTY) { - @Override - protected PersistenceXml buildValue_() { - return subject.getPersistenceXml(); - } - }; - } - - private PropertyValueModel<JpaRootContextNode> buildRootContextNodeHolder() { - return new TransformationPropertyValueModel<JpaProject, JpaRootContextNode>(buildJpaProjectHolder()) { - @Override - protected JpaRootContextNode transform_(JpaProject value) { - return value.getRootContextNode(); - } - }; - } - - private WidgetFactory buildWidgetFactory() { - return new FormWidgetFactory( - new TabbedPropertySheetWidgetFactory() - ); - } - - @Override - public void dispose() { - this.editorInputHolder.setValue(null); - this.resourceManager.dispose(); - super.dispose(); - } - - @Override - public void doSave(IProgressMonitor monitor) { - getEditor(getPageCount() - 1).doSave(monitor); - } - - @Override - public void doSaveAs() { - } - - @Override - public IFileEditorInput getEditorInput() { - return (IFileEditorInput) super.getEditorInput(); - } - - @Override - public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { - Assert.isLegal(editorInput instanceof IFileEditorInput, "Invalid Input: Must be IFileEditorInput"); - super.init(site, editorInput); - - setPartName(editorInput.getName()); - editorInputHolder.setValue(getEditorInput()); - } - - /** - * Initializes this multi-page editor. - */ - private void initialize() { - - widgetFactory = buildWidgetFactory(); - editorInputHolder = buildEditorInputHolder(); - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - /** - * Retrieves the JPA project associated with the project owning the editor - * intput file. - * - * @return The JPA project - */ - protected JpaProject getJpaProject() { - return JptJpaCorePlugin.getJpaProject(getEditorInput().getFile().getProject()); - } - - /** - * This extension over <code>FormPage</code> simply complete the layout by - * using the <code>JpaPageComposite</code>'s control as its form content. - */ - private class Page extends FormPage { - - /** - * The wrapped page that actually contains the widgets to show with this - * form page. - */ - private final JpaPageComposite page; - - private ImageDescriptor imageDescriptor; - - /** - * Creates a new <code>Page</code>. - * - * @param page The wrapped <code>JpaPageComposite</code> - */ - private Page(JpaPageComposite page) { - - super(PersistenceEditor.this, - page.getClass().getName(), - page.getPageText()); - - this.page = page; - } - - @Override - protected void createFormContent(IManagedForm managedForm) { - - ScrolledForm form = managedForm.getForm(); - managedForm.getToolkit().decorateFormHeading(form.getForm()); - - // Update the text and image - updateForm(form); - - // Update the layout - updateBody(form); - - // This will finish the initialization of the buttons - updateHelpButton(); - form.updateToolBar(); - } - - @Override - public void dispose() { - this.page.dispose(); - if (this.imageDescriptor != null) { - PersistenceEditor.this.resourceManager.destroyImage(this.imageDescriptor); - } - super.dispose(); - } - - @Override - public void setFocus() { - this.page.getControl().setFocus(); - } - - /** - * Adds the page's control to this page. - * - * @param form The form containing the composite with which the page's - * control is parented - */ - private void updateBody(ScrolledForm form) { - - Composite body = form.getBody(); - - body.setLayout(new TableWrapLayout()); - - TableWrapData wrapData = new TableWrapData( - TableWrapData.FILL_GRAB, - TableWrapData.FILL_GRAB - ); - - this.page.getControl().setLayoutData(wrapData); - this.page.getControl().setParent(body); - } - - /** - * Updates the text and image of the form. - * - * @param form The form to have its title bar updated by setting the text - * and image, the image can be <code>null</code> - */ - private void updateForm(ScrolledForm form) { - form.setText(this.page.getPageText()); - - this.imageDescriptor = this.page.getPageImageDescriptor(); - if (this.imageDescriptor != null) { - form.setImage(PersistenceEditor.this.resourceManager.createImage(this.imageDescriptor)); - } - } - - /** - * Adds a help button to the page's toolbar if a help ID exists. - */ - private void updateHelpButton() { - - String helpID = this.page.getHelpID(); - - if (helpID != null) { - Action helpAction = new HelpAction(helpID); - - ScrolledForm form = getManagedForm().getForm(); - IToolBarManager manager = form.getToolBarManager(); - manager.add(helpAction); - } - } - - private class HelpAction extends Action { - - private final String helpID; - - HelpAction(String helpID) { - super(JptUiPersistenceMessages.PersistenceEditor_page_help, - JFaceResources.getImageRegistry().getDescriptor(Dialog.DLG_IMG_HELP)); - - this.helpID = helpID; - } - - @Override - public void run() { - BusyIndicator.showWhile(getManagedForm().getForm().getDisplay(), new Runnable() { - public void run() { - PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpID); - } - }); - } - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jface/JarFileItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jface/JarFileItemLabelProvider.java deleted file mode 100644 index 79033cccc8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jface/JarFileItemLabelProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jface; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JarFile; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class JarFileItemLabelProvider extends AbstractItemLabelProvider -{ - public JarFileItemLabelProvider( - JarFile jarFile, DelegatingContentAndLabelProvider labelProvider) { - super(jarFile, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.JAR_FILE)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(((JarFile) model()).getResource().getName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - JarFile jarFile = (JarFile) model(); - return new StaticPropertyValueModel<String>( - jarFile.getResource().getName() - + " - " + jarFile.getResource().getParent().getFullPath().makeRelative().toString()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jface/XmlMappingFileViewerFilter.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jface/XmlMappingFileViewerFilter.java deleted file mode 100644 index b9f63a083e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jface/XmlMappingFileViewerFilter.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jface; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; - -/** - * This filter will deny showing any file that are not XML mapping files or folders - * that don't contain any XML mapping files in its sub-hierarchy. An XML mapping - * file is one that has a corresponding JpaFile in the project with a mapping file - * content type. - * @see JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE - */ -public class XmlMappingFileViewerFilter - extends ViewerFilter { - - private final JpaProject jpaProject; - - - public XmlMappingFileViewerFilter(JpaProject jpaProject) { - super(); - this.jpaProject = jpaProject; - } - - - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - - if (element instanceof IFile) { - return isMappingFile((IFile) element); - } - else if (element instanceof IContainer) { - IContainer container = (IContainer) element; - IProject project = this.jpaProject.getProject(); - if (JptCommonCorePlugin.getResourceLocator(project).acceptResourceLocation(project, container)) { - try { - for (IResource resource : container.members()) { - if (select(viewer, container, resource)) { - return true; - } - } - } - catch (CoreException ce) { - // fall through - JptJpaUiPlugin.log(ce); - } - } - } - return false; - } - - /** - * Determines whether the given file (an XML file) is a JPA mapping - * descriptor file. - */ - private boolean isMappingFile(IFile file) { - JpaFile jpaFile = this.jpaProject.getJpaFile(file); - return jpaFile != null ? jpaFile.getContentType().isKindOf(JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE): false; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/Generic2_0JpaPlatformUiProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/Generic2_0JpaPlatformUiProvider.java deleted file mode 100644 index 49c0736364..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/Generic2_0JpaPlatformUiProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2; - -import java.util.List; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.AbstractJpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaPersistentAttributeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaPersistentTypeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.EntityMappingsDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentAttributeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentTypeDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmXmlUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.java.Generic2_0JavaResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.EntityMappings2_0DetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmXml2_0UiDefinition; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceXml2_0UiDefinition; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.PersistenceXmlUiDefinition; - -/** - * All the state in the JPA platform should be "static" (i.e. unchanging once - * it is initialized). - */ -public class Generic2_0JpaPlatformUiProvider extends AbstractJpaPlatformUiProvider -{ - - // singleton - private static final JpaPlatformUiProvider INSTANCE = new Generic2_0JpaPlatformUiProvider(); - - /** - * Return the singleton. - */ - public static JpaPlatformUiProvider instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private Generic2_0JpaPlatformUiProvider() { - super(); - } - - - // ********** details providers ********** - - @Override - protected void addDetailsProvidersTo(List<JpaDetailsProvider> providers) { - providers.add(JavaPersistentTypeDetailsProvider.instance()); - providers.add(JavaPersistentAttributeDetailsProvider.instance()); - providers.add(EntityMappingsDetailsProvider.instance()); - providers.add(OrmPersistentTypeDetailsProvider.instance()); - providers.add(OrmPersistentAttributeDetailsProvider.instance()); - providers.add(EntityMappings2_0DetailsProvider.instance()); - } - - - // ********** resource ui definitions ********** - - @Override - protected void addResourceUiDefinitionsTo(List<ResourceUiDefinition> definitions) { - definitions.add(Generic2_0JavaResourceUiDefinition.instance()); - definitions.add(OrmXmlUiDefinition.instance()); - definitions.add(OrmXml2_0UiDefinition.instance()); - definitions.add(PersistenceXmlUiDefinition.instance()); - definitions.add(PersistenceXml2_0UiDefinition.instance()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/GenericOrmXml2_0UiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/GenericOrmXml2_0UiFactory.java deleted file mode 100644 index 91409a7de4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/GenericOrmXml2_0UiFactory.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.jpa2; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TransientMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.BaseOrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmBasicMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmElementCollectionMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmEmbeddedIdMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmEmbeddedMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmEntity2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmIdMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmManyToManyMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmManyToOneMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmOneToManyMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmOneToOneMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.OrmVersionMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.jpa2.details.orm.OrmXmlUiFactory2_0; -import org.eclipse.swt.widgets.Composite; - -public class GenericOrmXml2_0UiFactory - extends BaseOrmXmlUiFactory - implements OrmXmlUiFactory2_0 -{ - // **************** orm type mapping composites **************************** - - @Override - public JpaComposite createOrmEntityComposite( - PropertyValueModel<OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEntity2_0Composite(subjectHolder, parent, widgetFactory); - } - - - // **************** orm attribute mapping composites *********************** - - @Override - public JpaComposite createOrmIdMappingComposite( - PropertyValueModel<OrmIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmIdMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmEmbeddedIdMappingComposite( - PropertyValueModel<OrmEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEmbeddedIdMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmBasicMappingComposite( - PropertyValueModel<OrmBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmBasicMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmVersionMappingComposite( - PropertyValueModel<OrmVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmVersionMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmManyToOneMappingComposite( - PropertyValueModel<OrmManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmManyToOneMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmOneToManyMappingComposite( - PropertyValueModel<OrmOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmOneToManyMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmOneToOneMappingComposite( - PropertyValueModel<OrmOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmOneToOneMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmManyToManyMappingComposite( - PropertyValueModel<OrmManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmManyToManyMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmEmbeddedMappingComposite( - PropertyValueModel<OrmEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmEmbeddedMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createOrmTransientMappingComposite( - PropertyValueModel<OrmTransientMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new TransientMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmElementCollectionMapping2_0Composite( - PropertyValueModel<OrmElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OrmElementCollectionMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/Jpa2_0ProjectFlagModel.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/Jpa2_0ProjectFlagModel.java deleted file mode 100644 index 182674ef75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/Jpa2_0ProjectFlagModel.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2; - -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; - -/** - * Flag indicating whether the JPA project supports JPA 2.0. - */ -public class Jpa2_0ProjectFlagModel<T extends JpaNode> - extends TransformationPropertyValueModel<T, Boolean> -{ - public Jpa2_0ProjectFlagModel(PropertyValueModel<T> jpaProjectModel) { - super(jpaProjectModel); - } - - @Override - protected Boolean transform_(T value) { - return Boolean.valueOf(JptJpaCorePlugin.nodeIsJpa2_0Compatible(value)); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractElementCollectionMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractElementCollectionMapping2_0Composite.java deleted file mode 100644 index e1afecc33d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractElementCollectionMapping2_0Composite.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.jpt.jpa.core.context.Column; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.ConvertibleMapping; -import org.eclipse.jpt.jpa.core.context.EnumeratedConverter; -import org.eclipse.jpt.jpa.core.context.LobConverter; -import org.eclipse.jpt.jpa.core.context.TemporalConverter; -import org.eclipse.jpt.jpa.core.jpa2.context.CollectionTable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EnumTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TemporalTypeComposite; -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.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | EnumTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | LobComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see BasicMapping - * @see OrderColumnComposite - * @see EnumTypeComposite - * @see FetchTypeComposite - * @see LobComposite - * @see OptionalComposite - * @see TemporalTypeComposite - * - * @version 2.3 - * @since 2.3 - */ -public abstract class AbstractElementCollectionMapping2_0Composite<T extends ElementCollectionMapping2_0> - extends Pane<T> - implements JpaComposite -{ - - private Composite basicValueComposite; - - private Composite embeddableValueComposite; - - /** - * Creates a new <code>BasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IBasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - protected AbstractElementCollectionMapping2_0Composite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - @Override - protected void initializeLayout(Composite container) { - initializeElementCollectionCollapsibleSection(container); - initializeValueCollapsibleSection(container); - initializeKeyCollapsibleSection(container); - initializeOrderingCollapsibleSection(container); - } - - protected void initializeElementCollectionCollapsibleSection(Composite container) { - container = addCollapsibleSection( - container, - JptUiDetailsMessages2_0.ElementCollectionSection_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE) - ); - - this.initializeElementCollectionSection(container); - } - - protected void initializeElementCollectionSection(Composite container) { - new TargetClassComposite(this, container); - new FetchTypeComposite(this, container); - new CollectionTable2_0Composite(this, buildCollectionTableHolder(), container); - } - - protected void initializeOrderingCollapsibleSection(Composite container) { - new Ordering2_0Composite(this, container); - } - - protected void initializeValueCollapsibleSection(Composite container) { - Composite valueSection = addCollapsibleSection( - container, - JptUiDetailsMessages2_0.AbstractElementCollectionMapping2_0_Composite_valueSectionTitle - ); - initializeValueSection(valueSection); - } - - protected void initializeKeyCollapsibleSection(Composite container) { - - } - - protected void initializeValueSection(Composite container) { - PageBook pageBook = new PageBook(container, SWT.NULL); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalIndent = 5; - pageBook.setLayoutData(gd); - - this.initializeBasicValueSection(pageBook); - this.initializeEmbeddableValueSection(pageBook); - - installValueControlSwitcher(pageBook); - } - - protected void initializeBasicValueSection(Composite container) { - this.basicValueComposite = addSubPane(container); - - new ColumnComposite(this, buildValueColumnHolder(), this.basicValueComposite); - - // type section - Composite converterSection = addCollapsibleSubSection( - this.basicValueComposite, - JptUiDetailsMessages.TypeSection_type, - new SimplePropertyValueModel<Boolean>(Boolean.FALSE) - ); - ((GridLayout) converterSection.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - converterSection, - JptUiDetailsMessages.TypeSection_default, - buildNoConverterHolder(), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - // Lob - Button lobButton = addRadioButton( - converterSection, - JptUiDetailsMessages.TypeSection_lob, - buildLobConverterHolder(), - null); - ((GridData) lobButton.getLayoutData()).horizontalSpan = 2; - - - PropertyValueModel<Converter> converterHolder = buildConverterHolder(); - // Temporal - addRadioButton( - converterSection, - JptUiDetailsMessages.TypeSection_temporal, - buildTemporalBooleanHolder(), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(converterHolder), converterSection, getWidgetFactory())); - - - // Enumerated - addRadioButton( - converterSection, - JptUiDetailsMessages.TypeSection_enumerated, - buildEnumeratedBooleanHolder(), - null); - registerSubPane(new EnumTypeComposite(buildEnumeratedConverterHolder(converterHolder), converterSection, getWidgetFactory())); - } - - protected void initializeEmbeddableValueSection(Composite container) { - this.embeddableValueComposite = new ElementCollectionValueOverridesComposite(this, container).getControl(); - } - - private void installValueControlSwitcher(PageBook pageBook) { - - new ControlSwitcher( - buildValueHolder(), - buildPaneTransformer(), - pageBook - ); - } - - protected PropertyValueModel<ElementCollectionMapping2_0.Type> buildValueHolder() { - return new PropertyAspectAdapter<T, ElementCollectionMapping2_0.Type>( - this.getSubjectHolder(), ElementCollectionMapping2_0.VALUE_TYPE_PROPERTY) { - @Override - protected ElementCollectionMapping2_0.Type buildValue_() { - return this.subject.getValueType(); - } - }; - } - - private Transformer<ElementCollectionMapping2_0.Type, Control> buildPaneTransformer() { - return new Transformer<ElementCollectionMapping2_0.Type, Control>() { - public Control transform(ElementCollectionMapping2_0.Type type) { - return AbstractElementCollectionMapping2_0Composite.this.transformValueType(type); - } - }; - } - - /** - * Given the selected override, return the control that will be displayed - */ - protected Control transformValueType(ElementCollectionMapping2_0.Type type) { - if (type == null) { - return null; - } - switch (type) { - case BASIC_TYPE : - return this.basicValueComposite; - case EMBEDDABLE_TYPE : - return this.embeddableValueComposite; - default : - return null; - } - } - - protected PropertyValueModel<CollectionTable2_0> buildCollectionTableHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, CollectionTable2_0>(getSubjectHolder()) { - @Override - protected CollectionTable2_0 buildValue_() { - return this.subject.getCollectionTable(); - } - }; - } - - protected PropertyValueModel<Column> buildValueColumnHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, Column>(getSubjectHolder()) { - @Override - protected Column buildValue_() { - return this.subject.getValueColumn(); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildNoConverterHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getConverter().getType() == null); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(null); - } - } - }; - } - - private WritablePropertyValueModel<Boolean> buildLobConverterHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getConverter(); - return Boolean.valueOf(converter.getType() == LobConverter.class); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(LobConverter.class); - } - } - }; - } - - private PropertyValueModel<Converter> buildConverterHolder() { - return new PropertyAspectAdapter<T, Converter>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getConverter(); - } - }; - } - - private PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return converter.getType() == TemporalConverter.class ? (TemporalConverter) converter : null; - } - }; - } - - private PropertyValueModel<EnumeratedConverter> buildEnumeratedConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, EnumeratedConverter>(converterHolder) { - @Override - protected EnumeratedConverter transform_(Converter converter) { - return converter.getType() == EnumeratedConverter.class ? (EnumeratedConverter) converter : null; - } - }; - } - - private WritablePropertyValueModel<Boolean> buildTemporalBooleanHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getConverter(); - return Boolean.valueOf(converter.getType() == TemporalConverter.class); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(TemporalConverter.class); - } - } - }; - } - - private WritablePropertyValueModel<Boolean> buildEnumeratedBooleanHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getConverter(); - return Boolean.valueOf(converter.getType() == EnumeratedConverter.class); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setConverter(EnumeratedConverter.class); - } - } - }; - } - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractElementCollectionMapping2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractElementCollectionMapping2_0UiDefinition.java deleted file mode 100644 index d7f1921540..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractElementCollectionMapping2_0UiDefinition.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappingUiDefinition; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractElementCollectionMapping2_0UiDefinition<M, T extends ElementCollectionMapping2_0> - extends AbstractMappingUiDefinition<M, T> -{ - protected AbstractElementCollectionMapping2_0UiDefinition() { - super(); - } - - - public Image getImage() { - return JpaMappingImageHelper.imageForAttributeMapping(getKey()); - } - - public String getLabel() { - return JptUiDetailsMessages2_0.ElementCollectionMapping2_0_label; - } - - public String getLinkLabel() { - return JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel; - } - - public String getKey() { - return MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractManyToOneMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractManyToOneMapping2_0Composite.java deleted file mode 100644 index c20c27a8e6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractManyToOneMapping2_0Composite.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneMapping2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToOneMappingComposite; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractManyToOneMapping2_0Composite<T extends ManyToOneMapping, R extends ManyToOneRelationship2_0> - extends AbstractManyToOneMappingComposite<T, R> -{ - protected AbstractManyToOneMapping2_0Composite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeManyToOneCollapsibleSection(container); - initializeDerivedIdentityCollapsibleSection(container); - initializeJoiningStrategyCollapsibleSection(container); - } - - protected void initializeDerivedIdentityCollapsibleSection(Composite container) { - new DerivedIdentity2_0Pane(this, buildDerivedIdentityHolder(), container); - } - - @Override - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new ManyToOneJoiningStrategy2_0Pane(this, buildJoiningHolder(), container); - } - - protected PropertyValueModel<DerivedIdentity2_0> buildDerivedIdentityHolder() { - return new PropertyAspectAdapter<T, DerivedIdentity2_0>(getSubjectHolder()) { - @Override - protected DerivedIdentity2_0 buildValue_() { - return ((ManyToOneMapping2_0) this.subject).getDerivedIdentity(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractOneToOneMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractOneToOneMapping2_0Composite.java deleted file mode 100644 index 3b158caadb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AbstractOneToOneMapping2_0Composite.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneMapping2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToOneMappingComposite; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractOneToOneMapping2_0Composite<T extends OneToOneMapping, R extends OneToOneRelationship2_0> - extends AbstractOneToOneMappingComposite<T, R> -{ - protected AbstractOneToOneMapping2_0Composite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - initializeOneToOneCollapsibleSection(container); - initializeDerivedIdentityCollapsibleSection(container); - initializeJoiningStrategyCollapsibleSection(container); - } - - protected void initializeDerivedIdentityCollapsibleSection(Composite container) { - new DerivedIdentity2_0Pane(this, buildDerivedIdentityHolder(), container); - } - - - protected PropertyValueModel<DerivedIdentity2_0> buildDerivedIdentityHolder() { - return new PropertyAspectAdapter<T, DerivedIdentity2_0>(getSubjectHolder()) { - @Override - protected DerivedIdentity2_0 buildValue_() { - return ((OneToOneMapping2_0) this.subject).getDerivedIdentity(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AssociationOverride2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AssociationOverride2_0Composite.java deleted file mode 100644 index e21bd86741..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/AssociationOverride2_0Composite.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AssociationOverrideComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EntityOverridesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnsComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JoinTableJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | JoinColumnJoiningStrategyPane | - * | JoinTableJoiningStrategyPane | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see AssociationOverride - * @see EntityOverridesComposite - The parent container - * @see JoinColumnsComposite - * - * @version 2.3 - * @since 1.0 - */ -public class AssociationOverride2_0Composite - extends AssociationOverrideComposite -{ - /** - * Creates a new <code>AssociationOverrideComposite</code>. - * - * @param subjectHolder The holder of the subject <code>AssociationOverride</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public AssociationOverride2_0Composite(Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyAssociationOverride> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title); - - addJoinColumnJoiningStrategyPane(composite); - - addJoinTableJoiningStrategyPane(composite); - - addSubPane(composite, 5); - } - - protected void addJoinTableJoiningStrategyPane(Composite container) { - new JoinTableJoiningStrategyPane(this, buildRelationshipModel(), container); - } - - private PropertyValueModel<ReadOnlyJoinTableRelationship> buildRelationshipModel() { - return new TransformationPropertyValueModel<ReadOnlyAssociationOverride, ReadOnlyJoinTableRelationship>(getSubjectHolder()) { - @Override - protected ReadOnlyJoinTableRelationship transform_(ReadOnlyAssociationOverride value) { - // all specified and virtual (mappings) overrides support join tables - return (ReadOnlyJoinTableRelationship) value.getRelationship(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Cacheable2_0Pane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Cacheable2_0Pane.java deleted file mode 100644 index 01abe5a0c1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Cacheable2_0Pane.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | [X] Cacheable (true/false) - * -----------------------------------------------------------------------------</pre> - * - * @see Cacheable2_0 - * @see JavaEntity2_0Composite - A container of this widget - * @see OrmEntity2_0Composite - A container of this widget - */ -public class Cacheable2_0Pane - extends Pane<Cacheable2_0> -{ - public Cacheable2_0Pane( - Pane<?> parentPane, - PropertyValueModel<? extends Cacheable2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages2_0.Entity_cacheableLabel, - buildCacheableBooleanHolder(), - buildCacheableStringHolder(), - JpaHelpContextIds.ENTITY_CACHEABLE - ); - } - - - private WritablePropertyValueModel<Boolean> buildCacheableBooleanHolder() { - return new PropertyAspectAdapter<Cacheable2_0, Boolean>( - getSubjectHolder(), - Cacheable2_0.DEFAULT_CACHEABLE_PROPERTY, - Cacheable2_0.SPECIFIED_CACHEABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedCacheable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedCacheable(value); - } - }; - } - - private PropertyValueModel<String> buildCacheableStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultCacheableHolder()) { - - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages2_0.Entity_cacheableWithDefaultLabel, defaultStringValue); - } - return JptUiDetailsMessages2_0.Entity_cacheableLabel; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultCacheableHolder() { - return new PropertyAspectAdapter<Cacheable2_0, Boolean>( - getSubjectHolder(), - Cacheable2_0.SPECIFIED_CACHEABLE_PROPERTY, - Cacheable2_0.DEFAULT_CACHEABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedCacheable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultCacheable()); - } - }; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/CascadePane2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/CascadePane2_0.java deleted file mode 100644 index b9990caac9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/CascadePane2_0.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.Cascade2_0; -import org.eclipse.jpt.jpa.ui.internal.details.CascadeComposite; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -public class CascadePane2_0<T extends Cascade2_0> - extends CascadeComposite<T> -{ - public CascadePane2_0( - Pane<? extends RelationshipMapping> parentPane, - PropertyValueModel<T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - public CascadePane2_0( - PropertyValueModel<T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeLayout(Composite container) { - // Cascade group - Group cascadeGroup = addCascadeGroup(container); - - // Container of the check boxes - container = addSubPane(cascadeGroup, 6, 8, 0, 0, 0); - - addAllCheckBox(container); - addPersistCheckBox(container); - addMergeCheckBox(container); - addRemoveCheckBox(container); - addRefreshCheckBox(container); - addDetachCheckBox(container); - } - - protected void addDetachCheckBox(Composite container) { - addCheckBox( - container, - JptUiDetailsMessages2_0.CascadePane2_0_detach, - buildCascadeTypeDetachHolder(), - null); - } - - protected WritablePropertyValueModel<Boolean> buildCascadeTypeDetachHolder() { - return new PropertyAspectAdapter<Cascade2_0, Boolean>(getSubjectHolder(), Cascade2_0.DETACH_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isDetach(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setDetach(value); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/CollectionTable2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/CollectionTable2_0Composite.java deleted file mode 100644 index c2b7dfb0c3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/CollectionTable2_0Composite.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyReferenceTable; -import org.eclipse.jpt.jpa.core.jpa2.context.CollectionTable2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnsComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ReferenceTableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.TableCombo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * The layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------ | - * | Name: | |v| | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Schema: | |v| | - * | ------------------------------------------------------------ | - * | ------------------------------------------------------------ | - * | Catalog: | |v| | - * | ------------------------------------------------------------ | - * | | - * | - Join Columns ---------------------------------------------------------- | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoinColumnsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link CollectionTable2_0} - * @see {@link JoinColumnsComposite - * - * @version 3.0 - * @since 3.0 - */ -public class CollectionTable2_0Composite - extends ReferenceTableComposite<ReadOnlyReferenceTable> -{ - /** - * Creates a new <code>CollectionTable2_0Composite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public CollectionTable2_0Composite( - Pane<?> parentPane, - PropertyValueModel<? extends ReadOnlyReferenceTable> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - /** - * Creates a new <code>CollectionTable2_0Composite</code>. - * - * @param subjectHolder The holder of the subject <code>CollectionTable2_0</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public CollectionTable2_0Composite(PropertyValueModel<? extends CollectionTable2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - // collection table group pane - container = addTitledGroup( - container, - JptUiDetailsMessages2_0.CollectionTable2_0Composite_title - ); - - int groupBoxMargin = getGroupBoxMargin(); - - // Name widgets - TableCombo<ReadOnlyReferenceTable> tableCombo = addTableCombo(container); - Composite tablePane = addPane(container, groupBoxMargin); - addLabeledComposite( - tablePane, - JptUiDetailsMessages2_0.CollectionTable2_0Composite_name, - tableCombo.getControl(), - JpaHelpContextIds.MAPPING_COLLECTION_TABLE_NAME - ); - - // schema widgets - SchemaCombo<ReadOnlyReferenceTable> schemaCombo = addSchemaCombo(container); - - addLabeledComposite( - tablePane, - JptUiDetailsMessages2_0.CollectionTable2_0Composite_schema, - schemaCombo.getControl(), - JpaHelpContextIds.MAPPING_COLLECTION_TABLE_SCHEMA - ); - - // catalog widgets - CatalogCombo<ReadOnlyReferenceTable> catalogCombo = addCatalogCombo(container); - - addLabeledComposite( - tablePane, - JptUiDetailsMessages2_0.CollectionTable2_0Composite_catalog, - catalogCombo.getControl(), - JpaHelpContextIds.MAPPING_COLLECTION_TABLE_CATALOG - ); - - // Join Columns group pane - Group joinColumnGroupPane = addTitledGroup( - container, - JptUiDetailsMessages2_0.CollectionTable2_0Composite_joinColumn - ); - - // Override Default Join Columns check box - this.overrideDefaultJoinColumnsCheckBox = addCheckBox( - addSubPane(joinColumnGroupPane, 8), - JptUiDetailsMessages2_0.CollectionTable2_0Composite_overrideDefaultJoinColumns, - buildOverrideDefaultJoinColumnHolder(), - null - ); - - this.joinColumnsComposite = new JoinColumnsComposite<ReadOnlyReferenceTable>( - this, - joinColumnGroupPane, - buildJoinColumnsEditor() - ); - - installJoinColumnsPaneEnabler(this.joinColumnsComposite); - } - - @Override - protected boolean tableIsVirtual(ReadOnlyReferenceTable collectionTable) { - return collectionTable.getPersistentAttribute().isVirtual(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/DerivedIdentity2_0Pane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/DerivedIdentity2_0Pane.java deleted file mode 100644 index 071d0aef2c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/DerivedIdentity2_0Pane.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import java.util.Collection; -import org.eclipse.jpt.common.ui.internal.widgets.ComboPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MapsIdDerivedIdentityStrategy2_0; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -public class DerivedIdentity2_0Pane - extends Pane<DerivedIdentity2_0> -{ - public DerivedIdentity2_0Pane( - Pane<?> parentPane, - PropertyValueModel<? extends DerivedIdentity2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages2_0.DerivedIdentity_title); - ((GridLayout) composite.getLayout()).numColumns = 2; - - addNullDerivedIdentityPane(composite); - addIdDerivedIdentityPane(composite); - addMapsIdDerivedIdentityPane(composite); - } - - protected void addNullDerivedIdentityPane(Composite parent) { - Button button = addRadioButton( - parent, - JptUiDetailsMessages2_0.DerivedIdentity_nullDerivedIdentity, - buildUsesNullDerivedIdentityStrategyHolder(), - null); - ((GridData) button.getLayoutData()).horizontalSpan = 2; - } - - protected WritablePropertyValueModel<Boolean> buildUsesNullDerivedIdentityStrategyHolder() { - return new PropertyAspectAdapter<DerivedIdentity2_0, Boolean>( - getSubjectHolder(), DerivedIdentity2_0.PREDOMINANT_DERIVED_IDENTITY_STRATEGY_PROPERTY) { - - @Override - protected Boolean buildValue_() { - return this.subject.usesNullDerivedIdentityStrategy(); - } - - @Override - protected void setValue_(Boolean value) { - // radio button - should only have true values here - if (value) { - this.subject.setNullDerivedIdentityStrategy(); - } - } - }; - } - - protected void addIdDerivedIdentityPane(Composite parent) { - Button button = addRadioButton( - parent, - JptUiDetailsMessages2_0.DerivedIdentity_idDerivedIdentity, - buildUsesIdDerivedIdentityStrategyHolder(), - null); - ((GridData) button.getLayoutData()).horizontalSpan = 2; - } - - protected WritablePropertyValueModel<Boolean> buildUsesIdDerivedIdentityStrategyHolder() { - return new PropertyAspectAdapter<DerivedIdentity2_0, Boolean>( - getSubjectHolder(), DerivedIdentity2_0.PREDOMINANT_DERIVED_IDENTITY_STRATEGY_PROPERTY) { - - @Override - protected Boolean buildValue_() { - return this.subject.usesIdDerivedIdentityStrategy(); - } - - @Override - protected void setValue_(Boolean value) { - // radio button - should only have true values here - if (value) { - this.subject.setIdDerivedIdentityStrategy(); - } - } - }; - } - - protected void addMapsIdDerivedIdentityPane(Composite parent) { - WritablePropertyValueModel<Boolean> usesMapsIdModel = buildUsesMapsIdDerivedIdentityStrategyHolder(); - addRadioButton( - parent, - JptUiDetailsMessages2_0.DerivedIdentity_mapsIdDerivedIdentity, - usesMapsIdModel, - null); - - buildMapsIdValueComboPane(parent, usesMapsIdModel); - } - - protected WritablePropertyValueModel<Boolean> buildUsesMapsIdDerivedIdentityStrategyHolder() { - return new PropertyAspectAdapter<DerivedIdentity2_0, Boolean>( - getSubjectHolder(), DerivedIdentity2_0.PREDOMINANT_DERIVED_IDENTITY_STRATEGY_PROPERTY) { - - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : this.subject.usesMapsIdDerivedIdentityStrategy(); - } - - @Override - protected void setValue_(Boolean value) { - // radio button - should only have true values here - if (value) { - this.subject.setMapsIdDerivedIdentityStrategy(); - } - } - }; - } - - protected ComboPane buildMapsIdValueComboPane(Composite parent, PropertyValueModel<Boolean> usesMapsIdModel) { - return new MapsIdValueComboPane(this, buildMapsIdStrategyHolder(), parent, usesMapsIdModel); - } - - protected PropertyValueModel<MapsIdDerivedIdentityStrategy2_0> buildMapsIdStrategyHolder() { - return new PropertyAspectAdapter<DerivedIdentity2_0, MapsIdDerivedIdentityStrategy2_0>(getSubjectHolder()) { - @Override - protected MapsIdDerivedIdentityStrategy2_0 buildValue_() { - return this.subject.getMapsIdDerivedIdentityStrategy(); - } - }; - } - - - private class MapsIdValueComboPane - extends ComboPane<MapsIdDerivedIdentityStrategy2_0> - { - public MapsIdValueComboPane( - Pane<?> parentPane, - PropertyValueModel<? extends MapsIdDerivedIdentityStrategy2_0> subjectHolder, - Composite parent, - PropertyValueModel<Boolean> enabledModel) { - - super(parentPane, subjectHolder, parent, enabledModel); - } - - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(MapsIdDerivedIdentityStrategy2_0.DEFAULT_VALUE_PROPERTY); - propertyNames.add(MapsIdDerivedIdentityStrategy2_0.SPECIFIED_VALUE_PROPERTY); - } - - @Override - protected String getValue() { - return (getSubject() == null) ? null : getSubject().getSpecifiedValue(); - } - - @Override - protected void setValue(String value) { - if (getSubject() != null) getSubject().setSpecifiedValue(value); - } - - @Override - protected boolean usesDefaultValue() { - return (getSubject() == null) ? true : getSubject().usesDefaultValue(); - } - - @Override - protected String getDefaultValue() { - return (getSubject() == null) ? null : getSubject().getDefaultValue(); - } - - @Override - protected Iterable<String> getValues() { - return (getSubject() == null) ? EmptyIterable.<String>instance() : getSubject().getSortedValueChoices(); - } - - @Override - protected String buildNullDefaultValueEntry() { - return buildNonNullDefaultValueEntry(JptUiDetailsMessages2_0.DerivedIdentity_mapsIdUnspecifiedValue); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ElementCollectionMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ElementCollectionMapping2_0Composite.java deleted file mode 100644 index a6af316ea0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ElementCollectionMapping2_0Composite.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | TargetClassComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | FetchTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | CollectionTableComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | OptionalComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | LobComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see BasicMapping - * @see OrderColumnComposite - * @see EnumTypeComposite - * @see FetchTypeComposite - * @see LobComposite - * @see OptionalComposite - * @see TemporalTypeComposite - * - * @version 2.3 - * @since 2.3 - */ -public class ElementCollectionMapping2_0Composite extends AbstractElementCollectionMapping2_0Composite<ElementCollectionMapping2_0> -{ - /** - * Creates a new <code>BasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IBasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public ElementCollectionMapping2_0Composite(PropertyValueModel<? extends ElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ElementCollectionValueOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ElementCollectionValueOverridesComposite.java deleted file mode 100644 index d956e31ec9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ElementCollectionValueOverridesComposite.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOverridesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AssociationOverrideComposite; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.PageBook; - -public final class ElementCollectionValueOverridesComposite - extends AbstractOverridesComposite<ElementCollectionMapping2_0> -{ - public ElementCollectionValueOverridesComposite( - Pane<? extends ElementCollectionMapping2_0> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected boolean supportsAssociationOverrides() { - return true; - } - - @Override - protected Pane<ReadOnlyAssociationOverride> buildAssociationOverridePane(PageBook pageBook, PropertyValueModel<ReadOnlyAssociationOverride> associationOverrideHolder) { - return new AssociationOverrideComposite(this, associationOverrideHolder, pageBook); - } - - @Override - protected PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, AttributeOverrideContainer>(getSubjectHolder()) { - @Override - protected AttributeOverrideContainer buildValue_() { - return this.subject.getValueAttributeOverrideContainer(); - } - }; - } - - @Override - protected PropertyValueModel<AssociationOverrideContainer> buildAssociationOverrideContainerHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, AssociationOverrideContainer>(getSubjectHolder()) { - @Override - protected AssociationOverrideContainer buildValue_() { - return this.subject.getValueAssociationOverrideContainer(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedIdMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedIdMapping2_0Composite.java deleted file mode 100644 index 9af3e40be9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedIdMapping2_0Composite.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EmbeddedMappingOverridesComposite; -import org.eclipse.swt.widgets.Composite; - -public class EmbeddedIdMapping2_0Composite - extends AbstractEmbeddedIdMappingComposite<EmbeddedIdMapping> -{ - public EmbeddedIdMapping2_0Composite( - PropertyValueModel<? extends EmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeEmbeddedIdSection(Composite container) { - new EmbeddedIdMapping2_0MappedByRelationshipPane(this, getSubjectHolder(), container); - new EmbeddedMappingOverridesComposite(this, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java deleted file mode 100644 index 1a1151e508..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.EmbeddedIdMapping2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MappedByRelationshipMapping2_0; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.part.PageBook; - -public class EmbeddedIdMapping2_0MappedByRelationshipPane<T extends EmbeddedIdMapping2_0> - extends Pane<T> -{ - Label mappedByRelationshipLabel; - - public EmbeddedIdMapping2_0MappedByRelationshipPane( - Pane<?> parentPane, - PropertyValueModel<T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - PageBook pageBook = new PageBook(container, SWT.NULL); - pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - this.mappedByRelationshipLabel = addLabel(pageBook, JptUiDetailsMessages2_0.EmbeddedIdMapping2_0MappedByRelationshipPane_label); - - new ControlSwitcher(buildIsMappedByRelationshipHolder(), buildPaneTransformer(), pageBook); - } - - protected WritablePropertyValueModel<Boolean> buildIsMappedByRelationshipHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), MappedByRelationshipMapping2_0.MAPPED_BY_RELATIONSHIP_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isMappedByRelationship()); - } - }; - } - - private Transformer<Boolean, Control> buildPaneTransformer() { - return new Transformer<Boolean, Control>() { - public Control transform(Boolean converter) { - if (converter == null || converter == Boolean.FALSE) { - return null; - } - return EmbeddedIdMapping2_0MappedByRelationshipPane.this.mappedByRelationshipLabel; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedMapping2_0OverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedMapping2_0OverridesComposite.java deleted file mode 100644 index 7fa55fae3e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/EmbeddedMapping2_0OverridesComposite.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.EmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.jpa2.context.EmbeddedMapping2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingOverridesComposite; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.PageBook; - -public class EmbeddedMapping2_0OverridesComposite - extends AbstractEmbeddedMappingOverridesComposite<EmbeddedMapping> -{ - public EmbeddedMapping2_0OverridesComposite( - Pane<? extends EmbeddedMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected boolean supportsAssociationOverrides() { - return true; - } - - @Override - protected PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder() { - return new PropertyAspectAdapter<EmbeddedMapping, AttributeOverrideContainer>(getSubjectHolder()) { - @Override - protected AttributeOverrideContainer buildValue_() { - return this.subject.getAttributeOverrideContainer(); - } - }; - } - - @Override - protected Pane<ReadOnlyAssociationOverride> buildAssociationOverridePane(PageBook pageBook, PropertyValueModel<ReadOnlyAssociationOverride> associationOverrideHolder) { - return new AssociationOverride2_0Composite(this, associationOverrideHolder, pageBook); - } - - @Override - protected PropertyValueModel<AssociationOverrideContainer> buildAssociationOverrideContainerHolder() { - return new PropertyAspectAdapter<EmbeddedMapping, AssociationOverrideContainer>(getSubjectHolder()) { - @Override - protected AssociationOverrideContainer buildValue_() { - return ((EmbeddedMapping2_0) this.subject).getAssociationOverrideContainer(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Entity2_0OverridesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Entity2_0OverridesComposite.java deleted file mode 100644 index b554a7dacf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Entity2_0OverridesComposite.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityOverridesComposite; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.PageBook; - -public class Entity2_0OverridesComposite - extends AbstractEntityOverridesComposite -{ - public Entity2_0OverridesComposite( - Pane<? extends Entity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - - @Override - protected Pane<ReadOnlyAssociationOverride> buildAssociationOverridePane(PageBook pageBook, PropertyValueModel<ReadOnlyAssociationOverride> associationOverrideHolder) { - return new AssociationOverride2_0Composite(this, associationOverrideHolder, pageBook); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Generation2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Generation2_0Composite.java deleted file mode 100644 index 94d06795ab..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Generation2_0Composite.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.ui.internal.details.GenerationComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Generation2_0Composite - */ -public class Generation2_0Composite extends GenerationComposite -{ - - public Generation2_0Composite( - Pane<?> parentPane, - PropertyValueModel<? extends GeneratorContainer> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void addSequenceGeneratorComposite(Composite container, int topMargin, int leftMargin) { - new SequenceGenerator2_0Composite( - this, - this.buildSequenceGeneratorHolder(), - this.addSubPane(container, topMargin, leftMargin), - this.buildSequenceGeneratorBuilder() - ); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java deleted file mode 100644 index 1381b5bbff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.Transformer; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.IdMapping2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MappedByRelationshipMapping2_0; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.part.PageBook; - - -public class IdMapping2_0MappedByRelationshipPane<T extends IdMapping2_0> - extends Pane<T> -{ - - Label mappedByRelationshipLabel; - - public IdMapping2_0MappedByRelationshipPane( - Pane<?> parentPane, - PropertyValueModel<T> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - PageBook pageBook = new PageBook(container, SWT.NULL); - pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - this.mappedByRelationshipLabel = addLabel(pageBook, JptUiDetailsMessages2_0.IdMapping2_0MappedByRelationshipPane_label); - - new ControlSwitcher(buildIsMappedByRelationshipHolder(), buildPaneTransformer(), pageBook); - } - - protected WritablePropertyValueModel<Boolean> buildIsMappedByRelationshipHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), MappedByRelationshipMapping2_0.MAPPED_BY_RELATIONSHIP_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.isMappedByRelationship()); - } - }; - } - - private Transformer<Boolean, Control> buildPaneTransformer() { - return new Transformer<Boolean, Control>() { - public Control transform(Boolean converter) { - if (converter == null || converter == Boolean.FALSE) { - return null; - } - return IdMapping2_0MappedByRelationshipPane.this.mappedByRelationshipLabel; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/IdMappingGeneration2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/IdMappingGeneration2_0Composite.java deleted file mode 100644 index c850727e35..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/IdMappingGeneration2_0Composite.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.ui.internal.details.IdMappingGenerationComposite; -import org.eclipse.jpt.jpa.ui.internal.details.SequenceGeneratorComposite; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.swt.widgets.Composite; - -/** - * IdMappingGeneration2_0Composite - */ -public class IdMappingGeneration2_0Composite extends IdMappingGenerationComposite -{ - - public IdMappingGeneration2_0Composite(Pane<? extends IdMapping> parentPane, Composite parent) { - super(parentPane, parent); - } - - @Override - protected SequenceGeneratorComposite buildSequenceGeneratorComposite( - Composite container, - PropertyValueModel<SequenceGenerator> sequenceGeneratorHolder, - GeneratorBuilder<SequenceGenerator> sequenceGeneratorBuilder, - int topMargin, - int leftMargin) { - - return new SequenceGenerator2_0Composite( - this, - sequenceGeneratorHolder, - this.addSubPane(container, topMargin, leftMargin), - sequenceGeneratorBuilder - ); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java deleted file mode 100644 index 02f251d197..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali mapping panes. - * - * @version 2.3 - * @since 2.3 - */ -public class JptUiDetailsMessages2_0 -{ - public static String CascadePane2_0_detach; - - public static String CollectionTable2_0Composite_title; - public static String CollectionTable2_0Composite_joinColumn; - public static String CollectionTable2_0Composite_name; - public static String CollectionTable2_0Composite_schema; - public static String CollectionTable2_0Composite_catalog; - public static String CollectionTable2_0Composite_overrideDefaultJoinColumns; - - public static String DerivedIdentity_title; - public static String DerivedIdentity_nullDerivedIdentity; - public static String DerivedIdentity_idDerivedIdentity; - public static String DerivedIdentity_mapsIdDerivedIdentity; - public static String DerivedIdentity_mapsIdUnspecifiedValue; - - public static String ElementCollectionMapping2_0_label; - public static String ElementCollectionMapping2_0_linkLabel; - - public static String ElementCollectionSection_title; - public static String AbstractElementCollectionMapping2_0_Composite_valueSectionTitle; - - public static String Entity_cacheableLabel; - public static String Entity_cacheableWithDefaultLabel; - - public static String EmbeddedIdMapping2_0MappedByRelationshipPane_label; - - public static String IdMapping2_0MappedByRelationshipPane_label; - - public static String OrderingComposite_orderColumn; - - public static String OrphanRemoval2_0Composite_orphanRemovalLabel; - public static String OrphanRemoval2_0Composite_orphanRemovalLabelDefault; - - public static String LockModeComposite_lockModeLabel; - - public static String LockModeComposite_read; - public static String LockModeComposite_write; - public static String LockModeComposite_optimistic; - public static String LockModeComposite_optimistic_force_increment; - public static String LockModeComposite_pessimistic_read; - public static String LockModeComposite_pessimistic_write; - public static String LockModeComposite_pessimistic_force_increment; - public static String LockModeComposite_none; - - public static String TargetClassComposite_label; - - private static final String BUNDLE_NAME = "jpt_ui_details2_0"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiDetailsMessages2_0.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiDetailsMessages2_0() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/LockModeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/LockModeComposite.java deleted file mode 100644 index b47a08b720..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/LockModeComposite.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.jpa2.context.LockModeType2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.NamedQuery2_0; -import org.eclipse.swt.widgets.Composite; - -/** - * LockModeComposite - */ -public class LockModeComposite extends Pane<NamedQuery2_0> -{ - /** - * Creates a new <code>LockModeComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public LockModeComposite(Pane<? extends NamedQuery2_0> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - this.addLabeledComposite( - container, - JptUiDetailsMessages2_0.LockModeComposite_lockModeLabel, - this.addLockModeTypeCombo(container), - null // TODO - ); - } - - private EnumFormComboViewer<NamedQuery2_0, LockModeType2_0> addLockModeTypeCombo(Composite container) { - - return new EnumFormComboViewer<NamedQuery2_0, LockModeType2_0>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(NamedQuery2_0.DEFAULT_LOCK_MODE_PROPERTY); - propertyNames.add(NamedQuery2_0.SPECIFIED_LOCK_MODE_PROPERTY); - } - - @Override - protected LockModeType2_0[] getChoices() { - return LockModeType2_0.values(); - } - - @Override - protected LockModeType2_0 getDefaultValue() { - return this.getSubject().getDefaultLockMode(); - } - - @Override - protected String displayString(LockModeType2_0 value) { - return this.buildDisplayString( - JptUiDetailsMessages2_0.class, - LockModeComposite.this, - value - ); - } - - @Override - protected LockModeType2_0 getValue() { - return this.getSubject().getSpecifiedLockMode(); - } - - @Override - protected void setValue(LockModeType2_0 value) { - this.getSubject().setSpecifiedLockMode(value); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ManyToOneJoiningStrategy2_0Pane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ManyToOneJoiningStrategy2_0Pane.java deleted file mode 100644 index 8e01f1ef5b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/ManyToOneJoiningStrategy2_0Pane.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToOneRelationship; -import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JoinTableJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o JoinColumnStrategyPane ____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableJoiningStrategyPane_______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToOneMapping} - * @see {@link ManyToOneRelationship} - * @see {@link OrmManyToOneMappingComposite} - * @see {@link JoinColumnStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class ManyToOneJoiningStrategy2_0Pane extends Pane<ManyToOneRelationship2_0> -{ - public ManyToOneJoiningStrategy2_0Pane( - Pane<?> parentPane, - PropertyValueModel<? extends ManyToOneRelationship2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinColumnJoiningLabel, - JoinColumnJoiningStrategyPane.buildUsesJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinTableJoiningLabel, - JoinTableJoiningStrategyPane.buildUsesJoinTableJoiningStrategyHolder(getSubjectHolder()), - null); - - new JoinTableJoiningStrategyPane(this, composite); - - addSubPane(composite, 5); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java deleted file mode 100644 index 037037b257..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.NamedQuery2_0; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.NamedQueryPropertyComposite; -import org.eclipse.jpt.jpa.ui.internal.details.QueryHintsComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * NamedQueryProperty2_0Composite - */ -public class NamedQueryProperty2_0Composite extends NamedQueryPropertyComposite<NamedQuery2_0> -{ - /** - * Creates a new <code>NamedQueryProperty2_0Composite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - */ - public NamedQueryProperty2_0Composite(Pane<?> parentPane, - PropertyValueModel<NamedQuery2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - this.addLabeledText( - container, - JptUiDetailsMessages.NamedQueryComposite_nameTextLabel, - this.buildNameTextHolder()); - - // Query text area - this.addLabeledMultiLineText( - container, - JptUiDetailsMessages.NamedQueryPropertyComposite_query, - this.buildQueryHolder(), - 4, - null - ); - - new LockModeComposite(this, container); - - // Query Hints pane - container = this.addTitledGroup( - this.addSubPane(container, 5), - JptUiDetailsMessages.NamedQueryPropertyComposite_queryHintsGroupBox - ); - - new QueryHintsComposite(this, container); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OneToManyJoiningStrategy2_0Pane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OneToManyJoiningStrategy2_0Pane.java deleted file mode 100644 index 6ce3c6ce17..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OneToManyJoiningStrategy2_0Pane.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToManyRelationship; -import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JoinTableJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.MappedByJoiningStrategyPane; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableStrategyPane _____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OneToManyMapping} - * @see {@link OneToManyRelationship} - * @see {@link OrmOneToManyMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinTableStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class OneToManyJoiningStrategy2_0Pane - extends Pane<OneToManyRelationship2_0> -{ - public OneToManyJoiningStrategy2_0Pane( - Pane<?> parentPane, - PropertyValueModel<? extends OneToManyRelationship2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_mappedByLabel, - MappedByJoiningStrategyPane.buildUsesMappedByJoiningStrategyHolder(getSubjectHolder()), - null); - - new MappedByJoiningStrategyPane(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinColumnJoiningLabel, - JoinColumnJoiningStrategyPane.buildUsesJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinTableJoiningLabel, - JoinTableJoiningStrategyPane.buildUsesJoinTableJoiningStrategyHolder(getSubjectHolder()), - null); - - new JoinTableJoiningStrategyPane(this, composite); - - addSubPane(composite, 5); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OneToOneJoiningStrategy2_0Pane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OneToOneJoiningStrategy2_0Pane.java deleted file mode 100644 index 79f70503af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OneToOneJoiningStrategy2_0Pane.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.core.context.OneToOneRelationship; -import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.JoinColumnJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JoinTableJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.MappedByJoiningStrategyPane; -import org.eclipse.jpt.jpa.ui.internal.details.OneToOneMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.PrimaryKeyJoinColumnJoiningStrategyPane; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinColumnStrategyPane ____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableJoiningStrategyPane_______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o PrimaryKeyJoinColumnStrategyPane __________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OneToOneMapping} - * @see {@link OneToOneRelationship} - * @see {@link OneToOneMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinColumnStrategyPane} - * @see {@link PrimaryKeyJoinColumnStrategyPane} - * - * @version 2.3 - * @since 2.1 - */ -public class OneToOneJoiningStrategy2_0Pane - extends Pane<OneToOneRelationship2_0> -{ - public OneToOneJoiningStrategy2_0Pane( - Pane<?> parentPane, - PropertyValueModel<? extends OneToOneRelationship2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - Composite composite = addCollapsibleSection( - container, - JptUiDetailsMessages.Joining_title, - new SimplePropertyValueModel<Boolean>(Boolean.TRUE)); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_mappedByLabel, - MappedByJoiningStrategyPane.buildUsesMappedByJoiningStrategyHolder(getSubjectHolder()), - null); - - new MappedByJoiningStrategyPane(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_primaryKeyJoinColumnJoiningLabel, - PrimaryKeyJoinColumnJoiningStrategyPane.buildUsesPrimaryKeyJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - new PrimaryKeyJoinColumnJoiningStrategyPane(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinColumnJoiningLabel, - JoinColumnJoiningStrategyPane.buildUsesJoinColumnJoiningStrategyHolder(getSubjectHolder()), - null); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox(this, composite); - - addRadioButton( - composite, - JptUiDetailsMessages.Joining_joinTableJoiningLabel, - JoinTableJoiningStrategyPane.buildUsesJoinTableJoiningStrategyHolder(getSubjectHolder()), - null); - - new JoinTableJoiningStrategyPane(this, composite); - - addSubPane(composite, 5); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OrderColumnComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OrderColumnComposite.java deleted file mode 100644 index f5601a87d1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OrderColumnComposite.java +++ /dev/null @@ -1,370 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.jpa2.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.BaseColumn; -import org.eclipse.jpt.jpa.core.context.NamedColumn; -import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.db.ColumnCombo; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnCombo | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | > Details | - * | | - * | x Insertable | - * | | - * | x Updatable | - * | | - * | x Nullable | - * | | - * | ---------------------------------------------------- | - * | Column Definition: | I | | - * | ---------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * * - * @version 3.0 - * @since 3.0 - */ -public class OrderColumnComposite extends Pane<OrderColumn2_0> { - - /** - * Creates a new <code>ColumnComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of the subject <code>IColumn</code> - * @param parent The parent container - */ - public OrderColumnComposite(Pane<?> parentPane, - PropertyValueModel<? extends OrderColumn2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - /** - * Creates a new <code>ColumnComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of the subject <code>IColumn</code> - * @param parent The parent container - * @param automaticallyAlignWidgets <code>true</code> to make the widgets - * this pane aligned with the widgets of the given parent controller; - * <code>false</code> to not align them - */ - public OrderColumnComposite(Pane<?> parentPane, - PropertyValueModel<? extends OrderColumn2_0> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets); - } - - /** - * Creates a new <code>ColumnComposite</code>. - * - * @param parentPane The parent container of this one - * @param subjectHolder The holder of the subject <code>IColumn</code> - * @param parent The parent container - * @param automaticallyAlignWidgets <code>true</code> to make the widgets - * this pane aligned with the widgets of the given parent controller; - * <code>false</code> to not align them - */ - public OrderColumnComposite(Pane<?> parentPane, - PropertyValueModel<? extends OrderColumn2_0> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets, - boolean parentManagePane) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets, parentManagePane); - } - - private ColumnCombo<OrderColumn2_0> addColumnCombo(Composite container) { - - return new ColumnCombo<OrderColumn2_0>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(NamedColumn.DEFAULT_NAME_PROPERTY); - propertyNames.add(NamedColumn.SPECIFIED_NAME_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return getSubject().getDefaultName(); - } - - @Override - protected void setValue(String value) { - getSubject().setSpecifiedName(value); - } - - @Override - protected Table getDbTable_() { - return getSubject().getDbTable(); - } - - @Override - protected String getValue() { - return getSubject().getSpecifiedName(); - } - @Override - public String toString() { - return "OrderColumnComposite.columnCombo"; //$NON-NLS-1$ - } - }; - } - - private WritablePropertyValueModel<String> buildColumnDefinitionHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, String>(getSubjectHolder(), NamedColumn.COLUMN_DEFINITION_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getColumnDefinition(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setColumnDefinition(value); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildInsertableHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, Boolean>(getSubjectHolder(), BaseColumn.SPECIFIED_INSERTABLE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedInsertable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedInsertable(value); - } - }; - } - - private PropertyValueModel<String> buildInsertableStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultInsertableHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_insertableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_insertable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultInsertableHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, Boolean>( - getSubjectHolder(), - BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, - BaseColumn.DEFAULT_INSERTABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedInsertable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultInsertable()); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildNullableHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, Boolean>( - getSubjectHolder(), - BaseColumn.SPECIFIED_NULLABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedNullable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedNullable(value); - } - }; - } - - private PropertyValueModel<String> buildNullableStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultNullableHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_nullableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_nullable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultNullableHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, Boolean>( - getSubjectHolder(), - BaseColumn.SPECIFIED_NULLABLE_PROPERTY, - BaseColumn.DEFAULT_NULLABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedNullable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultNullable()); - } - }; - } - - - private WritablePropertyValueModel<Boolean> buildUpdatableHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, Boolean>( - getSubjectHolder(), - BaseColumn.DEFAULT_UPDATABLE_PROPERTY, - BaseColumn.SPECIFIED_UPDATABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedUpdatable(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedUpdatable(value); - } - }; - } - - private PropertyValueModel<String> buildUpdatableStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultUpdatableHolder()) { - - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_updatableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_updatable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultUpdatableHolder() { - return new PropertyAspectAdapter<OrderColumn2_0, Boolean>( - getSubjectHolder(), - BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, - BaseColumn.DEFAULT_UPDATABLE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedUpdatable() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultUpdatable()); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - // Column widgets - addLabeledComposite( - container, - JptUiDetailsMessages.ColumnComposite_name, - addColumnCombo(container), - JpaHelpContextIds.MAPPING_ORDER_COLUMN_ORDERING_COLUMN - ); - - // Details sub-pane - container = addCollapsibleSubSection( - container, - JptUiDetailsMessages.ColumnComposite_details, - new SimplePropertyValueModel<Boolean>(Boolean.FALSE) - ); - - new DetailsComposite(this, getSubjectHolder(), addSubPane(container, 0, 16)); - } - - protected class DetailsComposite extends Pane<OrderColumn2_0> { - - public DetailsComposite(Pane<?> parentPane, - PropertyValueModel<? extends OrderColumn2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - @Override - protected void initializeLayout(Composite container) { - - // Insertable tri-state check box - addTriStateCheckBoxWithDefault( - addSubPane(container, 4), - JptUiDetailsMessages.ColumnComposite_insertable, - buildInsertableHolder(), - buildInsertableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_INSERTABLE - ); - - // Updatable tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_updatable, - buildUpdatableHolder(), - buildUpdatableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_UPDATABLE - ); - - // Nullable tri-state check box - addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages.ColumnComposite_nullable, - buildNullableHolder(), - buildNullableStringHolder(), - JpaHelpContextIds.MAPPING_COLUMN_NULLABLE - ); - - // Column Definition widgets - addLabeledText( - container, - JptUiDetailsMessages.ColumnComposite_columnDefinition, - buildColumnDefinitionHolder() - ); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Ordering2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Ordering2_0Composite.java deleted file mode 100644 index 4722746511..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Ordering2_0Composite.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.CollectionMapping; -import org.eclipse.jpt.jpa.core.context.Orderable; -import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOrderingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Ordering -------------------------------------------------------------- | - * | | | | - * | | o None | | - * | | | | - * | | o Primary Key | | - * | | | | - * | | o Custom | | - * | | ------------------------------------------------------------------- | | - * | | | I | | | - * | | ------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see CollectionMapping - * @see OrmManyToManyMappingComposite - A container of this pane - * @see OrmOneToManyMappingComposite - A container of this pane - * - * @version 2.3 - * @since 1.0 - */ -public class Ordering2_0Composite extends AbstractOrderingComposite -{ - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public Ordering2_0Composite(Pane<? extends CollectionMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IMultiRelationshipMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public Ordering2_0Composite(PropertyValueModel<? extends CollectionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - PropertyValueModel<Orderable> orderableHolder = buildOrderableHolder(); - - container = addCollapsibleSection( - container, - JptUiDetailsMessages.OrderingComposite_orderingGroup - ); - - // No Ordering radio button - addRadioButton( - container, - JptUiDetailsMessages.OrderingComposite_none, - buildNoOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_NO_ORDERING - ); - - // Order by Primary Key radio button - addRadioButton( - container, - JptUiDetailsMessages.OrderingComposite_primaryKey, - buildPrimaryKeyOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_PRIMARY_KEY_ORDERING - ); - - // Custom Ordering radio button - addRadioButton( - container, - JptUiDetailsMessages.OrderingComposite_custom, - buildCustomOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_CUSTOM_ORDERING - ); - - // Custom Ordering text field - addText( - addSubPane(container, 0, 16), - buildSpecifiedOrderByHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY, - buildCustomOrderingHolder(orderableHolder) - ); - - - // Order Column Ordering radio button - addRadioButton( - container, - JptUiDetailsMessages2_0.OrderingComposite_orderColumn, - buildOrderColumnOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_COLUMN_ORDERING - ); - - OrderColumnComposite orderColumnComposite = new OrderColumnComposite( - this, - buildOrderColumnHolder(orderableHolder), - addSubPane(container, 0, 16)); - - installOrderColumnCompositeEnabler(orderableHolder, orderColumnComposite); - } - - protected void installOrderColumnCompositeEnabler(PropertyValueModel<Orderable> orderableHolder, OrderColumnComposite pane) { - new PaneEnabler(buildPaneEnablerHolder(orderableHolder), pane); - } - - private PropertyValueModel<Boolean> buildPaneEnablerHolder(PropertyValueModel<Orderable> orderableHolder) { - return buildOrderColumnOrderingHolder(orderableHolder); - } - - - protected WritablePropertyValueModel<Boolean> buildOrderColumnOrderingHolder(PropertyValueModel<Orderable> orderableHolder) { - return new PropertyAspectAdapter<Orderable, Boolean>(orderableHolder, Orderable2_0.ORDER_COLUMN_ORDERING_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(((Orderable2_0) this.subject).isOrderColumnOrdering()); - } - - @Override - protected void setValue_(Boolean value) { - ((Orderable2_0) this.subject).setOrderColumnOrdering(value.booleanValue()); - } - }; - } - - protected PropertyValueModel<OrderColumn2_0> buildOrderColumnHolder(PropertyValueModel<Orderable> orderableHolder) { - return new PropertyAspectAdapter<Orderable, OrderColumn2_0>(orderableHolder) { - @Override - protected OrderColumn2_0 buildValue_() { - return ((Orderable2_0) this.subject).getOrderColumn(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OrphanRemoval2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OrphanRemoval2_0Composite.java deleted file mode 100644 index 01845d77cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/OrphanRemoval2_0Composite.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovable2_0; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | [X] Orphan removal (true/false) | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OrphanRemovable2_0} - * @see {@link JavaOneToOneMapping2_0Composite} - A container of this widget - * @see {@link OrmOneToOneMapping2_0Composite} - A container of this widget - */ -public class OrphanRemoval2_0Composite extends Pane<OrphanRemovable2_0> -{ - /** - * Creates a new <code>OrphanRemoval2_0Composite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OrphanRemoval2_0Composite( - Pane<? extends RelationshipMapping> parentPane, - PropertyValueModel<? extends OrphanRemovable2_0> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - this.addTriStateCheckBoxWithDefault( - container, - JptUiDetailsMessages2_0.OrphanRemoval2_0Composite_orphanRemovalLabel, - this.buildOrphanRemovalHolder(), - this.buildOrphanRemovalStringHolder(), - null // TODO - ); - } - private WritablePropertyValueModel<Boolean> buildOrphanRemovalHolder() { - return new PropertyAspectAdapter<OrphanRemovable2_0, Boolean>( - this.getSubjectHolder(), - OrphanRemovable2_0.DEFAULT_ORPHAN_REMOVAL_PROPERTY, - OrphanRemovable2_0.SPECIFIED_ORPHAN_REMOVAL_PROPERTY) { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedOrphanRemoval(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedOrphanRemoval(value); - } - }; - } - - private PropertyValueModel<String> buildOrphanRemovalStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(this.buildDefaultOrphanRemovalHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages2_0.OrphanRemoval2_0Composite_orphanRemovalLabelDefault, defaultStringValue); - } - return JptUiDetailsMessages2_0.OrphanRemoval2_0Composite_orphanRemovalLabel; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultOrphanRemovalHolder() { - return new PropertyAspectAdapter<OrphanRemovable2_0, Boolean>( - this.getSubjectHolder(), - OrphanRemovable2_0.SPECIFIED_ORPHAN_REMOVAL_PROPERTY, - OrphanRemovable2_0.DEFAULT_ORPHAN_REMOVAL_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedOrphanRemoval() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultOrphanRemoval()); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java deleted file mode 100644 index 669669b674..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.core.jpa2.context.NamedQuery2_0; -import org.eclipse.jpt.jpa.ui.internal.details.NamedQueryPropertyComposite; -import org.eclipse.jpt.jpa.ui.internal.details.QueriesComposite; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.PageBook; - -/** - * Queries2_0Composite - */ -public class Queries2_0Composite - extends QueriesComposite -{ - public Queries2_0Composite( - Pane<?> parentPane, - PropertyValueModel<? extends QueryContainer> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected NamedQueryPropertyComposite<NamedQuery2_0> buildNamedQueryPropertyComposite(PageBook pageBook) { - return new NamedQueryProperty2_0Composite( - this, - this.buildNamedQuery2_0Holder(), - pageBook); - } - - protected PropertyValueModel<NamedQuery2_0> buildNamedQuery2_0Holder() { - return new TransformationPropertyValueModel<Query, NamedQuery2_0>(this.getQueryHolder()) { - @Override - protected NamedQuery2_0 transform_(Query value) { - return (value instanceof NamedQuery) ? (NamedQuery2_0) value : null; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/SequenceGenerator2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/SequenceGenerator2_0Composite.java deleted file mode 100644 index 22a92db8fb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/SequenceGenerator2_0Composite.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.jpa2.context.SequenceGenerator2_0; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.jpa.ui.internal.details.SequenceGeneratorComposite; -import org.eclipse.jpt.jpa.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.jpa.ui.internal.details.db.SchemaCombo; -import org.eclipse.swt.widgets.Composite; - -/** - * JavaSequenceGenerator2_0Composite - */ -public class SequenceGenerator2_0Composite extends SequenceGeneratorComposite -{ - - public SequenceGenerator2_0Composite(Pane<?> parentPane, - PropertyValueModel<SequenceGenerator> subjectHolder, - Composite parent, - GeneratorBuilder<SequenceGenerator> builder) { - - super(parentPane, subjectHolder, parent, builder); - } - - @Override - protected void initializeLayout(Composite container) { - - // Name widgets - this.addLabeledText( - container, - JptUiDetailsMessages.SequenceGeneratorComposite_name, - this.buildGeneratorNameHolder(), - JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_NAME - ); - - // Sequence Generator widgets - this.addLabeledComposite( - container, - JptUiDetailsMessages.SequenceGeneratorComposite_sequence, - this.buildSequenceNameCombo(container), - JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_SEQUENCE - ); - - // Schema widgets - this.addLabeledComposite( - container, - JptUiDetailsMessages.SequenceGeneratorComposite_schema, - this.addSchemaCombo(container), - null // JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_SCHEMA - ); - - // Catalog widgets - this.addLabeledComposite( - container, - JptUiDetailsMessages.SequenceGeneratorComposite_catalog, - this.addCatalogCombo(container), - null // JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_CATALOG - ); - - this.addAllocationSizeCombo(container); - this.addInitialValueCombo(container); - } - - private SchemaCombo<SequenceGenerator> addSchemaCombo(Composite container) { - - return new SchemaCombo<SequenceGenerator>(this, getSubjectHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(SequenceGenerator2_0.DEFAULT_SCHEMA_PROPERTY); - propertyNames.add(SequenceGenerator2_0.SPECIFIED_SCHEMA_PROPERTY); - propertyNames.add(SequenceGenerator2_0.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(SequenceGenerator2_0.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == SequenceGenerator2_0.DEFAULT_CATALOG_PROPERTY - || propertyName == SequenceGenerator2_0.SPECIFIED_CATALOG_PROPERTY ) { - repopulateComboBox(); - } - else { - super.propertyChanged(propertyName); - } - } - - @Override - protected String getDefaultValue() { - return ((SequenceGenerator2_0) getSubject()).getDefaultSchema(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return SequenceGenerator2_0Composite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - ((SequenceGenerator2_0) SequenceGenerator2_0Composite.this.retrieveGenerator()).setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return ((SequenceGenerator2_0) getSubject()).getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer() { - SequenceGenerator2_0 tg = (SequenceGenerator2_0) this.getSubject(); - if (tg != null) { - return tg.getDbSchemaContainer(); - } - return SequenceGenerator2_0Composite.this.getSubject().getContextDefaultDbSchemaContainer(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - // we overrode #getDbSchemaContainer() instead - throw new UnsupportedOperationException(); - } - }; - } - - private CatalogCombo<SequenceGenerator> addCatalogCombo(Composite container) { - - return new CatalogCombo<SequenceGenerator>(this, getSubjectHolder(), container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(SequenceGenerator2_0.DEFAULT_CATALOG_PROPERTY); - propertyNames.add(SequenceGenerator2_0.SPECIFIED_CATALOG_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return ((SequenceGenerator2_0) getSubject()).getDefaultCatalog(); - } - - @Override - protected boolean nullSubjectIsAllowed() { - return true; - } - - /** - * subject may be null, so delegate to the composite - */ - @Override - protected JpaProject getJpaProject() { - return SequenceGenerator2_0Composite.this.getJpaProject(); - } - - @Override - protected void setValue(String value) { - ((SequenceGenerator2_0) SequenceGenerator2_0Composite.this.retrieveGenerator()).setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return ((SequenceGenerator2_0) getSubject()).getSpecifiedCatalog(); - } - }; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/TargetClassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/TargetClassComposite.java deleted file mode 100644 index 2f82995d38..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/TargetClassComposite.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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 -*******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserComboPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * target entity hyperlink label, combo and browse button - */ -public class TargetClassComposite extends ClassChooserComboPane<ElementCollectionMapping2_0> -{ - - /** - * Creates a new <code>TargetEntityComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public TargetClassComposite( - Pane<? extends ElementCollectionMapping2_0> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected String getClassName() { - return getSubject().getTargetClass(); - } - - @Override - protected void setClassName(String className) { - this.getSubject().setSpecifiedTargetClass(className); - } - - @Override - protected char getEnclosingTypeSeparator() { - return getSubject().getTargetClassEnclosingTypeSeparator(); - } - - @Override - protected String getLabelText() { - return JptUiDetailsMessages2_0.TargetClassComposite_label; - } - - @Override - protected String getHelpId() { - return JpaHelpContextIds.MAPPING_ELEMENT_COLLECTION_TARGET_CLASS; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, String>(this.getSubjectHolder(), ElementCollectionMapping2_0.SPECIFIED_TARGET_CLASS_PROPERTY) { - @Override - protected String buildValue_() { - - String name = this.subject.getSpecifiedTargetClass(); - if (name == null) { - name = TargetClassComposite.this.getDefaultValue(this.subject); - } - return name; - } - - @Override - protected void setValue_(String value) { - - if (getDefaultValue(this.subject).equals(value)) { - value = null; - } - this.subject.setSpecifiedTargetClass(value); - } - }; - } - - @Override - protected ListValueModel<String> buildClassListHolder() { - return this.buildDefaultProfilerListHolder(); - } - - private ListValueModel<String> buildDefaultProfilerListHolder() { - return new PropertyListValueModelAdapter<String>( - this.buildDefaultProfilerHolder() - ); - } - - private PropertyValueModel<String> buildDefaultProfilerHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, String>(this.getSubjectHolder(), ElementCollectionMapping2_0.DEFAULT_TARGET_CLASS_PROPERTY) { - @Override - protected String buildValue_() { - return TargetClassComposite.this.getDefaultValue(this.subject); - } - }; - } - - private String getDefaultValue(ElementCollectionMapping2_0 subject) { - String defaultValue = subject.getDefaultTargetClass(); - - if (defaultValue != null) { - return NLS.bind( - JptCommonUiMessages.DefaultWithOneParam, - defaultValue - ); - } - return JptCommonUiMessages.DefaultEmpty; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaResourceUiDefinition.java deleted file mode 100644 index f4964985db..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaResourceUiDefinition.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.java; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.java.AbstractJavaResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.DefaultBasicMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.DefaultEmbeddedMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaBasicMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaEmbeddableUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaEmbeddedIdMappingUDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaEmbeddedMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaEntityUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaIdMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaManyToManyMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaManyToOneMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaMappedSuperclassUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaOneToManyMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaOneToOneMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaTransientMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaVersionMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.java.NullJavaAttributeMappingUiDefinition; - -public class Generic2_0JavaResourceUiDefinition extends AbstractJavaResourceUiDefinition -{ - // singleton - private static final ResourceUiDefinition INSTANCE = new Generic2_0JavaResourceUiDefinition(); - - /** - * Return the singleton. - */ - public static ResourceUiDefinition instance() { - return INSTANCE; - } - - - /** - * zero-argument constructor - */ - protected Generic2_0JavaResourceUiDefinition() { - super(); - } - - @Override - protected JavaUiFactory buildJavaUiFactory() { - return new Generic2_0JavaUiFactory(); - } - - @Override - protected void addSpecifiedAttributeMappingUiDefinitionsTo(List<JavaAttributeMappingUiDefinition<? extends AttributeMapping>> definitions) { - definitions.add(JavaElementCollectionMapping2_0UiDefinition.instance()); - definitions.add(JavaIdMappingUiDefinition.instance()); - definitions.add(JavaEmbeddedIdMappingUDefinition.instance()); - definitions.add(JavaBasicMappingUiDefinition.instance()); - definitions.add(JavaVersionMappingUiDefinition.instance()); - definitions.add(JavaManyToOneMappingUiDefinition.instance()); - definitions.add(JavaOneToManyMappingUiDefinition.instance()); - definitions.add(JavaOneToOneMappingUiDefinition.instance()); - definitions.add(JavaManyToManyMappingUiDefinition.instance()); - definitions.add(JavaEmbeddedMappingUiDefinition.instance()); - definitions.add(JavaTransientMappingUiDefinition.instance()); - } - - @Override - protected void addDefaultAttributeMappingUiDefinitionsTo(List<DefaultJavaAttributeMappingUiDefinition<?>> definitions) { - definitions.add(DefaultBasicMappingUiDefinition.instance()); - definitions.add(DefaultEmbeddedMappingUiDefinition.instance()); - definitions.add(NullJavaAttributeMappingUiDefinition.instance()); - } - - @Override - protected void addSpecifiedTypeMappingUiDefinitionsTo(List<JavaTypeMappingUiDefinition<? extends TypeMapping>> definitions) { - definitions.add(JavaEntityUiDefinition.instance()); - definitions.add(JavaMappedSuperclassUiDefinition.instance()); - definitions.add(JavaEmbeddableUiDefinition.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java deleted file mode 100644 index 451c37f8e2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.ElementCollectionMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.EmbeddedIdMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.GenericPersistenceXmlUiFactory; -import org.eclipse.jpt.jpa.ui.jpa2.details.java.JavaUiFactory2_0; -import org.eclipse.swt.widgets.Composite; - -/** - * The default implementation of the UI factory required to show the information - * related to a JPA mapping (type or attribute). - * - * @see GenericPersistenceXmlUiFactory - * - * @version 1.0 - * @since 1.0 - */ -public class Generic2_0JavaUiFactory - extends BaseJavaUiFactory - implements JavaUiFactory2_0 -{ - // **************** java type mapping composites *************************** - - @Override - public JpaComposite createJavaMappedSuperclassComposite( - PropertyValueModel<JavaMappedSuperclass> subjectHolder, - Composite parent, WidgetFactory widgetFactory) { - return new JavaMappedSuperclass2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaEntityComposite( - PropertyValueModel<JavaEntity> subjectHolder, - Composite parent, WidgetFactory widgetFactory) { - return new JavaEntity2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaEmbeddableComposite( - PropertyValueModel<JavaEmbeddable> subjectHolder, - Composite parent, WidgetFactory widgetFactory) { - return new JavaEmbeddable2_0Composite(subjectHolder, parent, widgetFactory); - } - - - // **************** java attribute mapping composites ********************** - - @Override - public JpaComposite createJavaIdMappingComposite( - PropertyValueModel<JavaIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaIdMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaEmbeddedIdMappingComposite( - PropertyValueModel<JavaEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new EmbeddedIdMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaEmbeddedMappingComposite( - PropertyValueModel<JavaEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaEmbeddedMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaManyToManyMappingComposite( - PropertyValueModel<JavaManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaManyToManyMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaManyToOneMappingComposite( - PropertyValueModel<JavaManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaManyToOneMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaOneToManyMappingComposite( - PropertyValueModel<JavaOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaOneToManyMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - @Override - public JpaComposite createJavaOneToOneMappingComposite( - PropertyValueModel<JavaOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new JavaOneToOneMapping2_0Composite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createJavaElementCollectionMapping2_0Composite( - PropertyValueModel<JavaElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new ElementCollectionMapping2_0Composite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaElementCollectionMapping2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaElementCollectionMapping2_0UiDefinition.java deleted file mode 100644 index 42f5a7e56a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaElementCollectionMapping2_0UiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractElementCollectionMapping2_0UiDefinition; -import org.eclipse.jpt.jpa.ui.jpa2.details.java.JavaUiFactory2_0; -import org.eclipse.swt.widgets.Composite; - -public class JavaElementCollectionMapping2_0UiDefinition - extends AbstractElementCollectionMapping2_0UiDefinition<ReadOnlyPersistentAttribute, JavaElementCollectionMapping2_0> - implements JavaAttributeMappingUiDefinition<JavaElementCollectionMapping2_0> -{ - // singleton - private static final JavaElementCollectionMapping2_0UiDefinition INSTANCE = - new JavaElementCollectionMapping2_0UiDefinition(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingUiDefinition<JavaElementCollectionMapping2_0> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private JavaElementCollectionMapping2_0UiDefinition() { - super(); - } - - - public JpaComposite buildAttributeMappingComposite( - JavaUiFactory factory, - PropertyValueModel<JavaElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return ((JavaUiFactory2_0) factory).createJavaElementCollectionMapping2_0Composite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEmbeddable2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEmbeddable2_0Composite.java deleted file mode 100644 index a1fae294dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEmbeddable2_0Composite.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * This pane does not have any widgets. - * - * @see Embeddable - * @see EmbeddableUiProvider - * - * @version 2.3 - * @since 2.0 - */ -public class JavaEmbeddable2_0Composite extends AbstractEmbeddableComposite<JavaEmbeddable> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddableComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaEmbeddable2_0Composite(PropertyValueModel<? extends JavaEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - this.initializeEmbeddableCollapsibleSection(container); - } - - @Override - protected void initializeEmbeddableSection(Composite container) { - new AccessTypeComposite(this, buildAccessHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<JavaEmbeddable, AccessHolder>( - getSubjectHolder()) - { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEmbeddedMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEmbeddedMapping2_0Composite.java deleted file mode 100644 index 8713cc0415..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEmbeddedMapping2_0Composite.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.EmbeddedMapping2_0OverridesComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * - * @version 2.3 - * @since 1.0 - */ -public class JavaEmbeddedMapping2_0Composite extends AbstractEmbeddedMappingComposite<JavaEmbeddedMapping> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddedMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>EmbeddedMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaEmbeddedMapping2_0Composite(PropertyValueModel<? extends JavaEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeEmbeddedSection(Composite container) { - new EmbeddedMapping2_0OverridesComposite( - this, - container - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java deleted file mode 100644 index cc12ebd7f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EntityNameComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaInheritanceComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.JavaSecondaryTablesComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Cacheable2_0Pane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Entity2_0OverridesComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Queries2_0Composite; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for a Java entity. - * - * @see JavaEntity - * @see JavaSecondaryTablesComposite - * - * @version 2.3 - * @since 1.0 - */ -public class JavaEntity2_0Composite - extends AbstractEntityComposite<JavaEntity> -{ - /** - * Creates a new <code>JavaEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>JavaEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaEntity2_0Composite( - PropertyValueModel<? extends JavaEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeEntitySection(Composite container) { - new TableComposite(this, container); - new EntityNameComposite(this, container); - new AccessTypeComposite(this, buildAccessHolder(), container); - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - new Cacheable2_0Pane(this, buildCacheableHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<JavaEntity, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } - - protected PropertyValueModel<Cacheable2_0> buildCacheableHolder() { - return new PropertyAspectAdapter<JavaEntity, Cacheable2_0>(getSubjectHolder()) { - @Override - protected Cacheable2_0 buildValue_() { - return ((CacheableHolder2_0) this.subject).getCacheable(); - } - }; - } - - @Override - protected void initializeSecondaryTablesSection(Composite container) { - new JavaSecondaryTablesComposite(this, container); - } - - @Override - protected void initializeInheritanceSection(Composite container) { - new JavaInheritanceComposite(this, container); - } - - @Override - protected void initializeAttributeOverridesSection(Composite container) { - new Entity2_0OverridesComposite(this, container); - } - - @Override - protected void initializeQueriesSection(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) { - new Queries2_0Composite(this, queryContainerHolder, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaIdMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaIdMapping2_0Composite.java deleted file mode 100644 index 6ab367fabe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaIdMapping2_0Composite.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.IdMapping2_0MappedByRelationshipPane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.IdMappingGeneration2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class JavaIdMapping2_0Composite - extends AbstractIdMappingComposite<IdMapping> -{ - public JavaIdMapping2_0Composite( - PropertyValueModel<? extends IdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeIdSection(Composite container) { - new IdMapping2_0MappedByRelationshipPane(this, getSubjectHolder(), container); - new ColumnComposite(this, buildColumnHolder(), container); - } - - @Override - protected void initializeGenerationCollapsibleSection(Composite container) { - new IdMappingGeneration2_0Composite(this, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToManyMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToManyMapping2_0Composite.java deleted file mode 100644 index 55822090d6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToManyMapping2_0Composite.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Ordering2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class JavaManyToManyMapping2_0Composite - extends AbstractManyToManyMappingComposite<JavaManyToManyMapping, JavaManyToManyRelationship> -{ - public JavaManyToManyMapping2_0Composite( - PropertyValueModel<? extends JavaManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeManyToManySection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new CascadePane2_0(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - @Override - protected void initializeOrderingCollapsibleSection(Composite container) { - new Ordering2_0Composite(this, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToOneMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToOneMapping2_0Composite.java deleted file mode 100644 index dba1e697f4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToOneMapping2_0Composite.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractManyToOneMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.swt.widgets.Composite; - -public class JavaManyToOneMapping2_0Composite - extends AbstractManyToOneMapping2_0Composite<JavaManyToOneMapping, JavaManyToOneRelationship2_0> -{ - public JavaManyToOneMapping2_0Composite( - PropertyValueModel<? extends JavaManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeManyToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new CascadePane2_0(this, buildCascadeHolder(), addSubPane(container, 5)); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToOneMapping2_0Pane.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToOneMapping2_0Pane.java deleted file mode 100644 index 6ac5eb9eee..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaManyToOneMapping2_0Pane.java +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.jpa2.details.java; - -public class JavaManyToOneMapping2_0Pane -{} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaMappedSuperclass2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaMappedSuperclass2_0Composite.java deleted file mode 100644 index 0467f48b14..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaMappedSuperclass2_0Composite.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractMappedSuperclassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | IdClassComposite | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see MappedSuperclass - * @see BaseJavaUiFactory - The factory creating this pane - * @see IdClassComposite - * - * @version 2.3 - * @since 2.0 - */ -public class JavaMappedSuperclass2_0Composite - extends AbstractMappedSuperclassComposite<JavaMappedSuperclass> - implements JpaComposite -{ - /** - * Creates a new <code>MappedSuperclassComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public JavaMappedSuperclass2_0Composite( - PropertyValueModel<? extends JavaMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeMappedSuperclassSection(Composite container) { - new AccessTypeComposite(this, buildAccessHolder(), container); - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<JavaMappedSuperclass, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaOneToManyMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaOneToManyMapping2_0Composite.java deleted file mode 100644 index 1c946851a7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaOneToManyMapping2_0Composite.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovalHolder2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToManyRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OneToManyJoiningStrategy2_0Pane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Ordering2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OrphanRemoval2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class JavaOneToManyMapping2_0Composite - extends AbstractOneToManyMappingComposite<JavaOneToManyMapping, JavaOneToManyRelationship2_0> -{ - public JavaOneToManyMapping2_0Composite( - PropertyValueModel<? extends JavaOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeOneToManySection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new OrphanRemoval2_0Composite(this, this.buildOrphanRemovableHolder(), container); - new CascadePane2_0(this, this.buildCascadeHolder(), this.addSubPane(container, 5)); - } - - @Override - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new OneToManyJoiningStrategy2_0Pane(this, this.buildJoiningHolder(), container); - } - - @Override - protected void initializeOrderingCollapsibleSection(Composite container) { - new Ordering2_0Composite(this, container); - } - - protected PropertyValueModel<OrphanRemovable2_0> buildOrphanRemovableHolder() { - return new PropertyAspectAdapter<JavaOneToManyMapping, OrphanRemovable2_0>(this.getSubjectHolder()) { - @Override - protected OrphanRemovable2_0 buildValue_() { - return ((OrphanRemovalHolder2_0) this.subject).getOrphanRemoval(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaOneToOneMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaOneToOneMapping2_0Composite.java deleted file mode 100644 index 9cc8974a57..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/JavaOneToOneMapping2_0Composite.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovalHolder2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractOneToOneMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OneToOneJoiningStrategy2_0Pane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OrphanRemoval2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class JavaOneToOneMapping2_0Composite - extends AbstractOneToOneMapping2_0Composite<JavaOneToOneMapping, JavaOneToOneRelationship2_0> -{ - public JavaOneToOneMapping2_0Composite( - PropertyValueModel<? extends JavaOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeOneToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new OrphanRemoval2_0Composite(this, buildOrphanRemovableHolder(), container); - new CascadePane2_0(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - @Override - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new OneToOneJoiningStrategy2_0Pane(this, buildJoiningHolder(), container); - } - - protected PropertyValueModel<OrphanRemovable2_0> buildOrphanRemovableHolder() { - return new PropertyAspectAdapter<JavaOneToOneMapping, OrphanRemovable2_0>(getSubjectHolder()) { - @Override - protected OrphanRemovable2_0 buildValue_() { - return ((OrphanRemovalHolder2_0) this.subject).getOrphanRemoval(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java deleted file mode 100644 index 57bec22097..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.jpa.ui.internal.details.orm.AbstractEntityMappingsDetailsPage; -import org.eclipse.swt.widgets.Composite; - -/** - * EntityMappings2_0DetailsPage - */ -public class EntityMappings2_0DetailsPage extends AbstractEntityMappingsDetailsPage -{ - /** - * Creates a new <code>EntityMappings2_0DetailsPage</code>. - * - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public EntityMappings2_0DetailsPage(Composite parent, - WidgetFactory widgetFactory) { - - super(parent, widgetFactory); - } - - @Override - protected void initializeGeneratorsCollapsibleSection(Composite container) { - new EntityMappingsGenerators2_0Composite(this, container); - } - - @Override - protected void initializeQueriesCollapsibleSection(Composite container) { - new OrmQueries2_0Composite(this, container); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsProvider.java deleted file mode 100644 index 128a9e6b54..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsProvider.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityMappingsDetailsProvider; -import org.eclipse.swt.widgets.Composite; - -/** - * EntityMappings2_0DetailsProvider - */ -public class EntityMappings2_0DetailsProvider - extends AbstractEntityMappingsDetailsProvider -{ - // singleton - private static final JpaDetailsProvider INSTANCE = new EntityMappings2_0DetailsProvider(); - - - /** - * Return the singleton - */ - public static JpaDetailsProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private EntityMappings2_0DetailsProvider() { - super(); - } - - - @Override - protected boolean providesDetails(JptResourceType resourceType) { - return resourceType.equals(JptJpaCorePlugin.ORM_XML_2_0_RESOURCE_TYPE); - } - - public JpaDetailsPage<EntityMappings> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new EntityMappings2_0DetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappingsGenerators2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappingsGenerators2_0Composite.java deleted file mode 100644 index 293019a85d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/EntityMappingsGenerators2_0Composite.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite; -import org.eclipse.jpt.jpa.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.jpt.jpa.ui.internal.details.orm.EntityMappingsGeneratorsComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.SequenceGenerator2_0Composite; -import org.eclipse.swt.widgets.Composite; - -/** - * EntityMappingsGenerators2_0Composite - */ -public class EntityMappingsGenerators2_0Composite extends EntityMappingsGeneratorsComposite -{ - /** - * Creates a new <code>EntityMappingsGenerators2_0Composite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public EntityMappingsGenerators2_0Composite( - Pane<? extends EntityMappings> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected GeneratorComposite<SequenceGenerator> buildSequenceGeneratorComposite( - Composite parent, - PropertyValueModel<SequenceGenerator> sequenceGeneratorHolder, - GeneratorBuilder<SequenceGenerator> generatorBuilder) { - - return new SequenceGenerator2_0Composite( - this, - sequenceGeneratorHolder, - parent, - generatorBuilder - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmBasicMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmBasicMapping2_0Composite.java deleted file mode 100644 index 46a70b9cdc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmBasicMapping2_0Composite.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.BasicMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractBasicMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.swt.widgets.Composite; - -public class OrmBasicMapping2_0Composite extends AbstractBasicMappingComposite<BasicMapping> -{ - /** - * Creates a new <code>EclipseLink1_1OrmBasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>BasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmBasicMapping2_0Composite(PropertyValueModel<? extends BasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeBasicSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, addSubPane(container, 4)); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<BasicMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmElementCollectionMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmElementCollectionMapping2_0Composite.java deleted file mode 100644 index fcba7bd016..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmElementCollectionMapping2_0Composite.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractElementCollectionMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CollectionTable2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.TargetClassComposite; -import org.eclipse.swt.widgets.Composite; - -public class OrmElementCollectionMapping2_0Composite - extends AbstractElementCollectionMapping2_0Composite<ElementCollectionMapping2_0> -{ - /** - * Creates a new <code>EclipseLink1_1OrmBasicMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>BasicMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmElementCollectionMapping2_0Composite(PropertyValueModel<? extends ElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeElementCollectionSection(Composite container) { - new TargetClassComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - new FetchTypeComposite(this, container); - new CollectionTable2_0Composite(this, buildCollectionTableHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<ElementCollectionMapping2_0, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmElementCollectionMapping2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmElementCollectionMapping2_0UiDefinition.java deleted file mode 100644 index 7f7722056e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmElementCollectionMapping2_0UiDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractElementCollectionMapping2_0UiDefinition; -import org.eclipse.jpt.jpa.ui.jpa2.details.orm.OrmXmlUiFactory2_0; -import org.eclipse.swt.widgets.Composite; - -public class OrmElementCollectionMapping2_0UiDefinition - extends AbstractElementCollectionMapping2_0UiDefinition<ReadOnlyPersistentAttribute, OrmElementCollectionMapping2_0> - implements OrmAttributeMappingUiDefinition<OrmElementCollectionMapping2_0> -{ - // singleton - private static final OrmElementCollectionMapping2_0UiDefinition INSTANCE = - new OrmElementCollectionMapping2_0UiDefinition(); - - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition<OrmElementCollectionMapping2_0> instance() { - return INSTANCE; - } - - - /** - * Ensure single instance. - */ - private OrmElementCollectionMapping2_0UiDefinition() { - super(); - } - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel<OrmElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - return ((OrmXmlUiFactory2_0) factory).createOrmElementCollectionMapping2_0Composite(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEmbeddedIdMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEmbeddedIdMapping2_0Composite.java deleted file mode 100644 index d1ae124f01..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEmbeddedIdMapping2_0Composite.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EmbeddedMappingOverridesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.EmbeddedIdMapping2_0MappedByRelationshipPane; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddedIdMapping2_0Composite - extends AbstractEmbeddedIdMappingComposite<EmbeddedIdMapping> -{ - public OrmEmbeddedIdMapping2_0Composite( - PropertyValueModel<? extends EmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeEmbeddedIdSection(Composite container) { - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - - new EmbeddedIdMapping2_0MappedByRelationshipPane(this, getSubjectHolder(), container); - new EmbeddedMappingOverridesComposite(this, container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<EmbeddedIdMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEmbeddedMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEmbeddedMapping2_0Composite.java deleted file mode 100644 index 0913d9ec2b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEmbeddedMapping2_0Composite.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.EmbeddedMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddedMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.EmbeddedMapping2_0OverridesComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * @see BaseJavaUiFactory - The factory creating this pane - * - * @version 2.3 - * @since 2.2 - */ -public class OrmEmbeddedMapping2_0Composite - extends AbstractEmbeddedMappingComposite<EmbeddedMapping> -{ - /** - * Creates a new <code>EmbeddedMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>EmbeddedMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmEmbeddedMapping2_0Composite(PropertyValueModel<? extends EmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeEmbeddedSection(Composite container) { - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - - new EmbeddedMapping2_0OverridesComposite( - this, - container - ); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<EmbeddedMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java deleted file mode 100644 index a018170014..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.GeneratorContainer; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.EntityNameComposite; -import org.eclipse.jpt.jpa.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TableComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.AbstractOrmEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.MetadataCompleteComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmJavaClassChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Cacheable2_0Pane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Entity2_0OverridesComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Generation2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Queries2_0Composite; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for an ORM entity 2.0. - * - * @see OrmEntity - * @see Entity2_0OverridesComposite - */ -public class OrmEntity2_0Composite - extends AbstractOrmEntityComposite -{ - /** - * Creates a new <code>OrmEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>OrmEntity</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmEntity2_0Composite( - PropertyValueModel<? extends OrmEntity> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeEntitySection(Composite container) { - new OrmJavaClassChooser(this, getSubjectHolder(), container, false); - new TableComposite(this, container); - new EntityNameComposite(this, container); - new AccessTypeComposite(this, buildAccessHolder(), container); - new IdClassComposite(this, buildIdClassReferenceHolder(), container); - new Cacheable2_0Pane(this, buildCacheableHolder(), container); - new MetadataCompleteComposite(this, getSubjectHolder(), container); - } - - protected PropertyValueModel<Cacheable2_0> buildCacheableHolder() { - return new PropertyAspectAdapter<OrmEntity, Cacheable2_0>(getSubjectHolder()) { - @Override - protected Cacheable2_0 buildValue_() { - return ((CacheableHolder2_0) this.subject).getCacheable(); - } - }; - } - - @Override - protected void initializeAttributeOverridesSection(Composite container) { - new Entity2_0OverridesComposite(this, container); - } - - @Override - protected void initializeGeneratorsSection(Composite container, PropertyValueModel<GeneratorContainer> generatorContainerHolder) { - new Generation2_0Composite(this, generatorContainerHolder, container); - } - - @Override - protected void initializeQueriesSection(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) { - new Queries2_0Composite(this, queryContainerHolder, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmIdMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmIdMapping2_0Composite.java deleted file mode 100644 index 3717d093e0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmIdMapping2_0Composite.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractIdMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.IdMapping2_0MappedByRelationshipPane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.IdMappingGeneration2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class OrmIdMapping2_0Composite - extends AbstractIdMappingComposite<IdMapping> -{ - public OrmIdMapping2_0Composite( - PropertyValueModel<? extends IdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeIdSection(Composite container) { - new IdMapping2_0MappedByRelationshipPane(this, getSubjectHolder(), container); - new ColumnComposite(this, buildColumnHolder(), container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - } - - @Override - protected void initializeGenerationCollapsibleSection(Composite container) { - new IdMappingGeneration2_0Composite(this, container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<IdMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmManyToManyMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmManyToManyMapping2_0Composite.java deleted file mode 100644 index 136fbb7fd4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmManyToManyMapping2_0Composite.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ManyToManyMapping; -import org.eclipse.jpt.jpa.core.context.ManyToManyRelationship; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractManyToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Ordering2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class OrmManyToManyMapping2_0Composite - extends AbstractManyToManyMappingComposite<ManyToManyMapping, ManyToManyRelationship> -{ - /** - * Creates a new <code>ManyToManyMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IManyToManyMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmManyToManyMapping2_0Composite( - PropertyValueModel<? extends ManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeManyToManySection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - new FetchTypeComposite(this, container); - new CascadePane2_0(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - @Override - protected void initializeOrderingCollapsibleSection(Composite container) { - new Ordering2_0Composite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmManyToOneMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmManyToOneMapping2_0Composite.java deleted file mode 100644 index 15ca95d75c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmManyToOneMapping2_0Composite.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.ManyToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneRelationship2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractManyToOneMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.swt.widgets.Composite; - -public class OrmManyToOneMapping2_0Composite - extends AbstractManyToOneMapping2_0Composite<ManyToOneMapping, ManyToOneRelationship2_0> -{ - public OrmManyToOneMapping2_0Composite( - PropertyValueModel<? extends ManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeManyToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new CascadePane2_0(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<ManyToOneMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmOneToManyMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmOneToManyMapping2_0Composite.java deleted file mode 100644 index 352f358926..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmOneToManyMapping2_0Composite.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.OneToManyMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyRelationship2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovalHolder2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractOneToManyMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OneToManyJoiningStrategy2_0Pane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Ordering2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OrphanRemoval2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class OrmOneToManyMapping2_0Composite - extends AbstractOneToManyMappingComposite<OneToManyMapping, OneToManyRelationship2_0> -{ - public OrmOneToManyMapping2_0Composite( - PropertyValueModel<? extends OneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeOneToManySection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, this.buildAccessHolderHolder(), container); - new FetchTypeComposite(this, container); - new OrphanRemoval2_0Composite(this, this.buildOrphanRemovableHolder(), container); - new CascadePane2_0(this, this.buildCascadeHolder(), this.addSubPane(container, 5)); - } - - @Override - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new OneToManyJoiningStrategy2_0Pane(this, this.buildJoiningHolder(), container); - } - - @Override - protected void initializeOrderingCollapsibleSection(Composite container) { - new Ordering2_0Composite(this, container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<OneToManyMapping, AccessHolder>(this.getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } - - protected PropertyValueModel<OrphanRemovable2_0> buildOrphanRemovableHolder() { - return new PropertyAspectAdapter<OneToManyMapping, OrphanRemovable2_0>(this.getSubjectHolder()) { - @Override - protected OrphanRemovable2_0 buildValue_() { - return ((OrphanRemovalHolder2_0) this.subject).getOrphanRemoval(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmOneToOneMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmOneToOneMapping2_0Composite.java deleted file mode 100644 index a9cd556c85..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmOneToOneMapping2_0Composite.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.OneToOneMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneRelationship2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovalHolder2_0; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.FetchTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.OptionalComposite; -import org.eclipse.jpt.jpa.ui.internal.details.TargetEntityComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.AbstractOneToOneMapping2_0Composite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.CascadePane2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OneToOneJoiningStrategy2_0Pane; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.OrphanRemoval2_0Composite; -import org.eclipse.swt.widgets.Composite; - -public class OrmOneToOneMapping2_0Composite - extends AbstractOneToOneMapping2_0Composite<OneToOneMapping, OneToOneRelationship2_0> -{ - public OrmOneToOneMapping2_0Composite( - PropertyValueModel<? extends OneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - @Override - protected void initializeOneToOneSection(Composite container) { - new TargetEntityComposite(this, container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - new FetchTypeComposite(this, container); - new OptionalComposite(this, container); - new OrphanRemoval2_0Composite(this, buildOrphanRemovableHolder(), container); - new CascadePane2_0(this, buildCascadeHolder(), addSubPane(container, 5)); - } - - @Override - protected void initializeJoiningStrategyCollapsibleSection(Composite container) { - new OneToOneJoiningStrategy2_0Pane(this, buildJoiningHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<OneToOneMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } - - protected PropertyValueModel<OrphanRemovable2_0> buildOrphanRemovableHolder() { - return new PropertyAspectAdapter<OneToOneMapping, OrphanRemovable2_0>(getSubjectHolder()) { - @Override - protected OrphanRemovable2_0 buildValue_() { - return ((OrphanRemovalHolder2_0) this.subject).getOrphanRemoval(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java deleted file mode 100644 index e60271eb8d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.QueryContainer; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.internal.details.QueriesComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmQueriesComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Queries2_0Composite; -import org.eclipse.swt.widgets.Composite; - -/** - * OrmQueries2_0Composite - */ -public class OrmQueries2_0Composite extends OrmQueriesComposite { - - /** - * Creates a new <code>OrmQueries2_0Composite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OrmQueries2_0Composite(Pane<? extends EntityMappings> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected QueriesComposite buildQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) { - return new Queries2_0Composite(this, queryContainerHolder, container); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmVersionMapping2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmVersionMapping2_0Composite.java deleted file mode 100644 index 416aadd306..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmVersionMapping2_0Composite.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.AccessHolder; -import org.eclipse.jpt.jpa.core.context.VersionMapping; -import org.eclipse.jpt.jpa.ui.internal.details.AbstractVersionMappingComposite; -import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.jpa.ui.internal.details.ColumnComposite; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappingNameChooser; -import org.eclipse.swt.widgets.Composite; - -public class OrmVersionMapping2_0Composite - extends AbstractVersionMappingComposite<VersionMapping> -{ - /** - * Creates a new <code>EclipseLinkOrmVersionMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>VersionMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public OrmVersionMapping2_0Composite(PropertyValueModel<? extends VersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeVersionSection(Composite container) { - new ColumnComposite(this, buildColumnHolder(), container); - new OrmMappingNameChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolderHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolderHolder() { - return new PropertyAspectAdapter<VersionMapping, AccessHolder>(getSubjectHolder()) { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentAttribute(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmXml2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmXml2_0UiDefinition.java deleted file mode 100644 index c9bd67284d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmXml2_0UiDefinition.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.details.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.details.orm.AbstractOrmXmlResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmBasicMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEmbeddableUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEmbeddedIdMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEmbeddedMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmEntityUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmIdMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmManyToManyMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmManyToOneMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmMappedSuperclassUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmOneToManyMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmOneToOneMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmTransientMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmVersionMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.jpa2.GenericOrmXml2_0UiFactory; -import org.eclipse.jpt.jpa.ui.internal.structure.OrmResourceModelStructureProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class OrmXml2_0UiDefinition extends AbstractOrmXmlResourceUiDefinition -{ - // singleton - private static final ResourceUiDefinition INSTANCE = new OrmXml2_0UiDefinition(); - - - /** - * Return the singleton - */ - public static ResourceUiDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private OrmXml2_0UiDefinition() { - super(); - } - - - @Override - protected OrmXmlUiFactory buildOrmXmlUiFactory() { - return new GenericOrmXml2_0UiFactory(); - } - - public boolean providesUi(JptResourceType resourceType) { - return resourceType.equals(JptJpaCorePlugin.ORM_XML_2_0_RESOURCE_TYPE); - } - - public JpaStructureProvider getStructureProvider() { - return OrmResourceModelStructureProvider.instance(); - } - - @Override - protected void addOrmAttributeMappingUiDefinitionsTo(List<OrmAttributeMappingUiDefinition<? extends AttributeMapping>> definitions) { - definitions.add(OrmIdMappingUiDefinition.instance()); - definitions.add(OrmEmbeddedIdMappingUiDefinition.instance()); - definitions.add(OrmBasicMappingUiDefinition.instance()); - definitions.add(OrmVersionMappingUiDefinition.instance()); - definitions.add(OrmManyToOneMappingUiDefinition.instance()); - definitions.add(OrmOneToManyMappingUiDefinition.instance()); - definitions.add(OrmOneToOneMappingUiDefinition.instance()); - definitions.add(OrmManyToManyMappingUiDefinition.instance()); - definitions.add(OrmEmbeddedMappingUiDefinition.instance()); - definitions.add(OrmTransientMappingUiDefinition.instance()); - - definitions.add(OrmElementCollectionMapping2_0UiDefinition.instance()); - } - - @Override - protected void addOrmTypeMappingUiDefinitionsTo(List<OrmTypeMappingUiDefinition<? extends TypeMapping>> definitions) { - definitions.add(OrmEntityUiDefinition.instance()); - definitions.add(OrmMappedSuperclassUiDefinition.instance()); - definitions.add(OrmEmbeddableUiDefinition.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java deleted file mode 100644 index a25815dedb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.persistence; - -import java.util.ArrayList; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.connection.GenericPersistenceUnit2_0ConnectionTab; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.options.GenericPersistenceUnit2_0OptionsTab; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.GenericPersistenceUnitGeneralComposite; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.PersistenceUnitPropertiesComposite; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.PersistenceXmlUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * The default implementation of the UI factory required to show the information - * related to a JPA mapping (type or attribute). - * - * @see GenericPersistenceXmlUiFactory - * - * @version 1.0 - * @since 1.0 - */ -public class Generic2_0PersistenceXmlUiFactory implements PersistenceXmlUiFactory -{ - - // **************** persistence unit composites **************************** - public ListIterator<JpaPageComposite> createPersistenceUnitComposites( - PropertyValueModel<PersistenceUnit> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - ArrayList<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(4); - - PropertyValueModel<JpaConnection2_0> connection2_0Holder = - this.buildJpaConnection2_0Holder(subjectHolder); - PropertyValueModel<JpaOptions2_0> options2_0Holder = - this.buildJpaOptions2_0Holder(subjectHolder); - - pages.add(new GenericPersistenceUnitGeneralComposite(subjectHolder, parent, widgetFactory)); - pages.add(new GenericPersistenceUnit2_0ConnectionTab(connection2_0Holder, parent, widgetFactory)); - pages.add(new GenericPersistenceUnit2_0OptionsTab(options2_0Holder, parent, widgetFactory)); - pages.add(new PersistenceUnitPropertiesComposite(subjectHolder, parent, widgetFactory)); - - return pages.listIterator(); - } - - // ********** private methods ********** - - private PropertyValueModel<JpaConnection2_0> buildJpaConnection2_0Holder( - PropertyValueModel<PersistenceUnit> subjectHolder) { - return new TransformationPropertyValueModel<PersistenceUnit, JpaConnection2_0>(subjectHolder) { - @Override - protected JpaConnection2_0 transform_(PersistenceUnit value) { - return (JpaConnection2_0) ((PersistenceUnit2_0) value).getConnection(); - } - }; - } - - private PropertyValueModel<JpaOptions2_0> buildJpaOptions2_0Holder( - PropertyValueModel<PersistenceUnit> subjectHolder) { - return new TransformationPropertyValueModel<PersistenceUnit, JpaOptions2_0>(subjectHolder) { - @Override - protected JpaOptions2_0 transform_(PersistenceUnit value) { - return (JpaOptions2_0) ((PersistenceUnit2_0) value).getOptions(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/JptUiPersistence2_0Messages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/JptUiPersistence2_0Messages.java deleted file mode 100644 index 634139d2bf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/JptUiPersistence2_0Messages.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence; - -import org.eclipse.osgi.util.NLS; - -/** - * JptUiPersistence2_0Messages - */ -public class JptUiPersistence2_0Messages -{ - // Connection - public static String ConnectionPropertiesComposite_Database_GroupBox; - - public static String DataSourcePropertiesComposite_jtaDataSourceLabel; - public static String DataSourcePropertiesComposite_nonJtaDataSourceLabel; - - public static String GenericPersistenceUnit2_0ConnectionComposite_sectionTitle; - public static String GenericPersistenceUnit2_0ConnectionComposite_sectionDescription; - public static String GenericPersistenceUnit2_0ConnectionTab_title; - - public static String GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionTitle; - public static String GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionDescription; - public static String GenericPersistenceUnit2_0OptionsTab_title; - public static String GenericPersistenceUnit2_0OptionsTab_noName; - - public static String JdbcConnectionPropertiesComposite_ConnectionDialog_Message; - public static String JdbcConnectionPropertiesComposite_ConnectionDialog_Title; - - public static String JdbcConnectionPropertiesComposite_populateFromConnectionHyperLink; - public static String JdbcConnectionPropertiesComposite_driverLabel; - public static String JdbcConnectionPropertiesComposite_urlLabel; - public static String JdbcConnectionPropertiesComposite_userLabel; - public static String JdbcConnectionPropertiesComposite_passwordLabel; - - public static String JdbcPropertiesComposite_JdbcConnectionProperties_GroupBox; - - public static String LockingConfigurationComposite_lockTimeoutLabel; - public static String QueryConfigurationComposite_queryTimeoutLabel; - - public static String TransactionTypeComposite_transactionTypeLabel; - - public static String TransactionTypeComposite_jta; - public static String TransactionTypeComposite_resource_local; - - public static String SharedCacheModeComposite_sharedCacheModeLabel; - - public static String SharedCacheModeComposite_all; - public static String SharedCacheModeComposite_none; - public static String SharedCacheModeComposite_enable_selective; - public static String SharedCacheModeComposite_disable_selective; - public static String SharedCacheModeComposite_unspecified; - - public static String ValidationModeComposite_validationModeLabel; - - public static String ValidationModeComposite_auto; - public static String ValidationModeComposite_callback; - public static String ValidationModeComposite_none; - - public static String ValidationConfigurationComposite_groupPrePersistLabel; - public static String ValidationConfigurationComposite_groupPreUpdateLabel; - public static String ValidationConfigurationComposite_groupPreRemoveLabel; - - - private static final String BUNDLE_NAME = "jpt_ui_persistence2_0"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiPersistence2_0Messages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiPersistence2_0Messages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java deleted file mode 100644 index c57412685f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.persistence; - -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.AbstractPersistenceXmlResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.persistence.details.PersistenceXmlUiFactory; -import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceResourceModelStructureProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class PersistenceXml2_0UiDefinition extends AbstractPersistenceXmlResourceUiDefinition -{ - // singleton - private static final ResourceUiDefinition INSTANCE = new PersistenceXml2_0UiDefinition(); - - - /** - * Return the singleton - */ - public static ResourceUiDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private PersistenceXml2_0UiDefinition() { - super(); - } - - - @Override - protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() { - return new Generic2_0PersistenceXmlUiFactory(); - } - - public boolean providesUi(JptResourceType resourceType) { - return resourceType.equals(JptJpaCorePlugin.PERSISTENCE_XML_2_0_RESOURCE_TYPE); - } - - public JpaStructureProvider getStructureProvider() { - return PersistenceResourceModelStructureProvider.instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/ConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/ConnectionPropertiesComposite.java deleted file mode 100644 index 4e37630532..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/ConnectionPropertiesComposite.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * ConnectionPropertiesComposite - */ -public class ConnectionPropertiesComposite extends Pane<JpaConnection2_0> -{ - public ConnectionPropertiesComposite(Pane<JpaConnection2_0> parentComposite, Composite parent) { - - super(parentComposite, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - container = addTitledGroup( - container, - JptUiPersistence2_0Messages.ConnectionPropertiesComposite_Database_GroupBox - ); - - new DataSourcePropertiesComposite(this, container); - new JdbcPropertiesComposite(this, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/DataSourcePropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/DataSourcePropertiesComposite.java deleted file mode 100644 index f35c3df2dc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/DataSourcePropertiesComposite.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * DataSourcePropertiesComposite - */ -public class DataSourcePropertiesComposite extends Pane<JpaConnection2_0> -{ - /** - * Creates a new <code>DataSourcePropertiesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public DataSourcePropertiesComposite(Pane<JpaConnection2_0> parentComposite, - Composite parent) { - - super(parentComposite, parent); - } - - private WritablePropertyValueModel<String> buildJtaDataSourceHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(this.buildPersistenceUnitHolder(), PersistenceUnit.JTA_DATA_SOURCE_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getJtaDataSource(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setJtaDataSource(value); - } - }; - } - - private PropertyValueModel<Boolean> buildJTADataSourceHolder() { - return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) { - @Override - protected Boolean transform(PersistenceUnitTransactionType value) { - return Boolean.valueOf(this.transform2(value)); - } - private boolean transform2(PersistenceUnitTransactionType value) { - return value == null || value == PersistenceUnitTransactionType.JTA; - } - }; - } - - private WritablePropertyValueModel<String> buildNonJtaDataSourceHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(buildPersistenceUnitHolder(), PersistenceUnit.NON_JTA_DATA_SOURCE_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getNonJtaDataSource(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setNonJtaDataSource(value); - } - }; - } - - private PropertyValueModel<Boolean> buildNonJTADataSourceHolder() { - return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) { - @Override - protected Boolean transform(PersistenceUnitTransactionType value) { - return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL); - } - }; - } - - private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() { - return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>( - buildPersistenceUnitHolder(), - PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY, - PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY) { - @Override - protected PersistenceUnitTransactionType buildValue_() { - return this.subject.getTransactionType(); - } - }; - } - - private PropertyValueModel<PersistenceUnit> buildPersistenceUnitHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, PersistenceUnit>(getSubjectHolder()) { - @Override - protected PersistenceUnit buildValue_() { - return this.subject.getPersistenceUnit(); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = this.getGroupBoxMargin(); - - container = this.addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - - // JTA Data Source - PropertyValueModel<Boolean> jtaEnabled = this.buildJTADataSourceHolder(); - Label jtaLabel = this.addLabel(container, JptUiPersistence2_0Messages.DataSourcePropertiesComposite_jtaDataSourceLabel, jtaEnabled); - Text jtaText = this.addText(container, this.buildJtaDataSourceHolder(), this.getHelpID(), jtaEnabled); - this.addLabeledComposite(container, jtaLabel, jtaText, this.getHelpID()); - - // Non-JTA Data Source - PropertyValueModel<Boolean> nonJTAEnabled = this.buildNonJTADataSourceHolder(); - Label nonJtaLabel = this.addLabel(container, JptUiPersistence2_0Messages.DataSourcePropertiesComposite_nonJtaDataSourceLabel, nonJTAEnabled); - Text nonJtaText = this.addText(container, this.buildNonJtaDataSourceHolder(), this.getHelpID(), nonJTAEnabled); - this.addLabeledComposite(container, nonJtaLabel, nonJtaText, this.getHelpID()); - } - - public String getHelpID() { - return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; // TODO - Review for JPA 2.0 - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/GenericPersistenceUnit2_0ConnectionComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/GenericPersistenceUnit2_0ConnectionComposite.java deleted file mode 100644 index 52ee14de9d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/GenericPersistenceUnit2_0ConnectionComposite.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * GenericPersistenceUnit2_0ConnectionComposite - */ -public class GenericPersistenceUnit2_0ConnectionComposite extends Pane<JpaConnection2_0> -{ - public GenericPersistenceUnit2_0ConnectionComposite( - Pane<JpaConnection2_0> subjectHolder, - Composite container) { - super(subjectHolder, container, false); - } - - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = this.getGroupBoxMargin() * 2; - - container = this.addSection( - container, - JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionTitle, - JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionDescription - ); - - Composite subPane = this.addSubPane( - container, - 0, groupBoxMargin, 10, groupBoxMargin - ); - - new TransactionTypeComposite(this, subPane); - - new ConnectionPropertiesComposite(this, container); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/GenericPersistenceUnit2_0ConnectionTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/GenericPersistenceUnit2_0ConnectionTab.java deleted file mode 100644 index a90d91c496..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/GenericPersistenceUnit2_0ConnectionTab.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; - -/** - * GenericPersistenceUnit2_0ConnectionTab - */ -public class GenericPersistenceUnit2_0ConnectionTab extends Pane<JpaConnection2_0> - implements JpaPageComposite -{ - // ********** constructors/initialization ********** - /** - * Creates a new <code>GenericPersistenceUnit2_0ConnectionTab</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public GenericPersistenceUnit2_0ConnectionTab( - PropertyValueModel<JpaConnection2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - new GenericPersistenceUnit2_0ConnectionComposite(this, container); - } - - // ********** Layout ********** - @Override - protected Composite addContainer(Composite parent) { - GridLayout layout = new GridLayout(1, true); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.marginTop = 0; - layout.marginLeft = 0; - layout.marginBottom = 0; - layout.marginRight = 0; - layout.verticalSpacing = 15; - Composite container = this.addPane(parent, layout); - updateGridData(container); - return container; - } - - private void updateGridData(Composite container) { - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } - - // ********** JpaPageComposite implementation ********** - - public String getHelpID() { - return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; // TODO - Review for JPA 2.0 - } - - public ImageDescriptor getPageImageDescriptor() { - return null; - } - - public String getPageText() { - return JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionTab_title; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcConnectionPropertiesComposite.java deleted file mode 100644 index 3b59a85a61..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcConnectionPropertiesComposite.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import java.util.Comparator; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.ConnectionProfileFactory; -import org.eclipse.jpt.jpa.db.JptJpaDbPlugin; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; - -/** - * JdbcConnectionPropertiesComposite - */ -@SuppressWarnings("nls") -public class JdbcConnectionPropertiesComposite extends Pane<JpaConnection2_0> -{ - /** - * The constant ID used to retrieve the dialog settings. - */ - private static final String DIALOG_SETTINGS = "org.eclipse.jpt.jpa.ui.internal.jpa2.dialogs.ConnectionDialog"; - - public JdbcConnectionPropertiesComposite(Pane<JpaConnection2_0> parentComposite, Composite parent) { - - super(parentComposite, parent); - } - - private WritablePropertyValueModel<String> buildPasswordHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, String>(this.getSubjectHolder(), JpaConnection2_0.PASSWORD_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getPassword(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setPassword(value); - } - }; - } - - private Runnable buildPopulateFromConnectionAction() { - return new Runnable() { - public void run() { - promptConnection(); - } - }; - } - - private WritablePropertyValueModel<String> buildUrlHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, String>(this.getSubjectHolder(), JpaConnection2_0.URL_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getUrl(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setUrl(value); - } - }; - } - - private WritablePropertyValueModel<String> buildUserHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, String>(this.getSubjectHolder(), JpaConnection2_0.USER_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getUser(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - this.subject.setUser(value); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - // Populate from Connection hyperlink - this.addHyperlink( - container, - JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_populateFromConnectionHyperLink, - this.buildPopulateFromConnectionAction() - ); - - // Driver - new JdbcDriverComposite(this, container); - - // Url - this.addLabeledText( - container, - JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_urlLabel, - this.buildUrlHolder() - ); - - // User - this.addLabeledText( - container, - JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_userLabel, - this.buildUserHolder() - ); - - // Password - this.addLabeledPasswordText( - container, - JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_passwordLabel, - this.buildPasswordHolder() - ); - } - - void promptConnection() { - - ConnectionSelectionDialog dialog = new ConnectionSelectionDialog(); - - if (dialog.open() != IDialogConstants.OK_ID) { - return; - } - - String name = (String) dialog.getResult()[0]; - ConnectionProfile cp = this.getConnectionProfileFactory().buildConnectionProfile(name); - - JpaConnection2_0 connection = getSubject(); - connection.setUrl((cp == null) ? "" : cp.getURL()); - connection.setUser((cp == null) ? "" : cp.getUserName()); - connection.setPassword((cp == null) ? "" : cp.getUserPassword()); - connection.setDriver((cp == null) ? "" : cp.getDriverClassName()); - } - - ConnectionProfileFactory getConnectionProfileFactory() { - // we allow the user to select any connection profile and simply - // take the settings from it (user, password, etc.) and give them - // to the persistence connection, so we go - // to the db plug-in directly to get the factory - return JptJpaDbPlugin.getConnectionProfileFactory(); - } - - // broaden access a bit - Shell getShell_() { - return this.getShell(); - } - - /** - * This dialog shows the list of possible connection names and lets the user - * the option to filter them using a search field. - */ - protected class ConnectionSelectionDialog extends FilteredItemsSelectionDialog { - - /** - * Creates a new <code>MappingSelectionDialog</code>. - */ - protected ConnectionSelectionDialog() { - super(JdbcConnectionPropertiesComposite.this.getShell_(), false); - this.setMessage(JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_ConnectionDialog_Message); - this.setTitle(JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_ConnectionDialog_Title); - this.setListLabelProvider(this.buildLabelProvider()); - this.setDetailsLabelProvider(this.buildLabelProvider()); - } - - protected ILabelProvider buildLabelProvider() { - return new LabelProvider() { - @Override - public Image getImage(Object element) { - return null; - } - - @Override - public String getText(Object element) { - return (element == null) ? "" : element.toString(); - } - }; - } - - @Override - protected Control createExtendedContentArea(Composite parent) { - return null; - } - - @Override - protected ItemsFilter createFilter() { - return new ConnectionItemsFilter(); - } - - @Override - protected void fillContentProvider(AbstractContentProvider provider, - ItemsFilter itemsFilter, - IProgressMonitor monitor) throws CoreException { - - monitor.beginTask(null, -1); - - try { - // Add the connection names to the dialog - for (String name : this.getConnectionProfileNames()) { - provider.add(name, itemsFilter); - } - } - finally { - monitor.done(); - } - } - - private Iterable<String> getConnectionProfileNames() { - return JdbcConnectionPropertiesComposite.this.getConnectionProfileFactory().getConnectionProfileNames(); - } - - @Override - protected IDialogSettings getDialogSettings() { - - IDialogSettings dialogSettings = JptJpaUiPlugin.instance().getDialogSettings(); - IDialogSettings settings = dialogSettings.getSection(DIALOG_SETTINGS); - - if (settings == null) { - settings = dialogSettings.addNewSection(DIALOG_SETTINGS); - } - return settings; - } - - @Override - public String getElementName(Object object) { - return object.toString(); - } - - @Override - protected Comparator<String> getItemsComparator() { - return new Comparator<String>() { - public int compare(String item1, String item2) { - return item1.compareTo(item2); - } - }; - } - - @Override - protected IStatus validateItem(Object item) { - - if (item == null) { - return new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, IStatus.ERROR, "", null); - } - return Status.OK_STATUS; - } - - /** - * Create the filter responsible to remove any connection name based on - * the pattern entered in the text field. - */ - private class ConnectionItemsFilter extends ItemsFilter { - - /** - * Creates a new <code>ConnectionItemsFilter</code>. - */ - ConnectionItemsFilter() { - - super(); - - // Make sure that if the pattern is empty, we specify * in order - // to show all the mapping types - if (StringTools.stringIsEmpty(getPattern())) { - patternMatcher.setPattern("*"); - } - } - - /* - * (non-Javadoc) - */ - @Override - public boolean isConsistentItem(Object item) { - return true; - } - - /* - * (non-Javadoc) - */ - @Override - public boolean matchItem(Object item) { - return matches(item.toString()); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcDriverComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcDriverComposite.java deleted file mode 100644 index cd1471328f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcDriverComposite.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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 -*******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.connection; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * JdbcDriverComposite - */ -public class JdbcDriverComposite extends Pane<JpaConnection2_0> -{ - /** - * Creates a new <code>JdbcDriverComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public JdbcDriverComposite(Pane<? extends JpaConnection2_0> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - private ClassChooserPane<JpaConnection2_0> initializeClassChooser(Composite container) { - - return new ClassChooserPane<JpaConnection2_0>(this, container) { - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, String>( - this.getSubjectHolder(), JpaConnection2_0.DRIVER_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getDriver(); - } - - @Override - protected void setValue_(String value) { - - if (value.length() == 0) { - value = null; - } - this.subject.setDriver(value); - } - }; - } - - @Override - protected String getClassName() { - return this.getSubject().getDriver(); - } - - @Override - protected String getLabelText() { - return JptUiPersistence2_0Messages.JdbcConnectionPropertiesComposite_driverLabel; - } - - @Override - protected IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } - - @Override - protected void setClassName(String className) { - this.getSubject().setDriver(className); - } - - @Override - protected boolean allowTypeCreation() { - //Does not make sense to allow the user to create a new Driver class - return false; - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - this.initializeClassChooser(container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcPropertiesComposite.java deleted file mode 100644 index 2ab54d50b5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/JdbcPropertiesComposite.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import org.eclipse.jpt.common.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * JdbcPropertiesComposite - */ -public class JdbcPropertiesComposite extends Pane<JpaConnection2_0> -{ - public JdbcPropertiesComposite(Pane<JpaConnection2_0> parentComposite, Composite parent) { - - super(parentComposite, parent); - } - - private PropertyValueModel<Boolean> buildPaneEnablerHolder() { - return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) { - @Override - protected Boolean transform(PersistenceUnitTransactionType value) { - return value == PersistenceUnitTransactionType.RESOURCE_LOCAL; - } - }; - } - - private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() { - return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>( - buildPersistenceUnitHolder(), - PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY, - PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY) { - @Override - protected PersistenceUnitTransactionType buildValue_() { - return this.subject.getTransactionType(); - } - }; - } - - private PropertyValueModel<PersistenceUnit> buildPersistenceUnitHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, PersistenceUnit>(getSubjectHolder()) { - @Override - protected PersistenceUnit buildValue_() { - return this.subject.getPersistenceUnit(); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - - container = addTitledGroup( - addSubPane(container, 10), - JptUiPersistence2_0Messages.JdbcPropertiesComposite_JdbcConnectionProperties_GroupBox - ); - - new JdbcConnectionPropertiesComposite(this, container); - - this.installPaneEnabler(); - } - - private void installPaneEnabler() { - new PaneEnabler(buildPaneEnablerHolder(), this); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/TransactionTypeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/TransactionTypeComposite.java deleted file mode 100644 index 179a6e5d2d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/connection/TransactionTypeComposite.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.connection; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * TransactionTypeComposite - */ -public class TransactionTypeComposite extends Pane<JpaConnection2_0> -{ - /** - * Creates a new <code>TransactionTypeComposite</code>. - * - * @param parentController - * The parent container of this one - * @param parent - * The parent container - */ - public TransactionTypeComposite( - Pane<? extends JpaConnection2_0> parentComposite, - Composite parent) { - - super( parentComposite, parent); - } - - private EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) { - - return new EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType>(this, - this.buildPersistenceUnitHolder(), - container) { - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY); - propertyNames.add(PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY); - } - - @Override - protected PersistenceUnitTransactionType[] getChoices() { - return PersistenceUnitTransactionType.values(); - } - - @Override - protected PersistenceUnitTransactionType getDefaultValue() { - return this.getSubject().getDefaultTransactionType(); - } - - @Override - protected String displayString(PersistenceUnitTransactionType value) { - return this.buildDisplayString(JptUiPersistence2_0Messages.class, TransactionTypeComposite.this, value); - } - - @Override - protected PersistenceUnitTransactionType getValue() { - return this.getSubject().getSpecifiedTransactionType(); - } - - @Override - protected void setValue(PersistenceUnitTransactionType value) { - this.getSubject().setSpecifiedTransactionType(value); - - if (value == PersistenceUnitTransactionType.RESOURCE_LOCAL) { - clearJTAProperties(); - } - else { - clearResourceLocalProperties(); - } - } - }; - } - - private PropertyValueModel<PersistenceUnit> buildPersistenceUnitHolder() { - return new PropertyAspectAdapter<JpaConnection2_0, PersistenceUnit>(this.getSubjectHolder()) { - @Override - protected PersistenceUnit buildValue_() { - return this.subject.getPersistenceUnit(); - } - }; - } - - private void clearJTAProperties() { - this.getSubject().getPersistenceUnit().setJtaDataSource(null); - } - - private void clearResourceLocalProperties() { - JpaConnection2_0 connection = this.getSubject(); - connection.getPersistenceUnit().setNonJtaDataSource(null); - connection.setDriver(null); - connection.setUrl(null); - connection.setUser(null); - connection.setPassword(null); - } - - @Override - protected void initializeLayout( Composite container) { - - this.addLabeledComposite( - container, - JptUiPersistence2_0Messages.TransactionTypeComposite_transactionTypeLabel, - this.buildTransactionTypeCombo( container), - JpaHelpContextIds.PERSISTENCE_XML_CONNECTION // TODO - Review for JPA 2.0 - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/GenericPersistenceUnit2_0OptionsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/GenericPersistenceUnit2_0OptionsComposite.java deleted file mode 100644 index dc2b64a91d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/GenericPersistenceUnit2_0OptionsComposite.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; - -/** - * GenericPersistenceUnit2_0OptionsComposite - */ -public class GenericPersistenceUnit2_0OptionsComposite extends Pane<JpaOptions2_0> -{ - public GenericPersistenceUnit2_0OptionsComposite( - Pane<JpaOptions2_0> subjectHolder, - Composite parent) { - - super(subjectHolder, parent, false); - } - - @Override - protected void initializeLayout(Composite parent) { - this.initializeMiscellaneousPane(parent); - } - - private void initializeMiscellaneousPane(Composite container) { - - this.updateGridData(container); - this.updateGridData(container.getParent()); - - Composite composite = this.addSection(container, - JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionTitle, - JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionDescription); - - this.updateGridData(composite); - this.updateGridData(composite.getParent()); - - new LockingConfigurationComposite(this, composite); - new QueryConfigurationComposite(this, composite); - new ValidationConfigurationComposite(this, composite); - - } - - private void updateGridData(Composite container) { - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/GenericPersistenceUnit2_0OptionsTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/GenericPersistenceUnit2_0OptionsTab.java deleted file mode 100644 index 955837017c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/GenericPersistenceUnit2_0OptionsTab.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; - -/** - * GenericPersistenceUnit2_0OptionsTab - */ -public class GenericPersistenceUnit2_0OptionsTab extends Pane<JpaOptions2_0> - implements JpaPageComposite -{ - // ********** constructors/initialization ********** - /** - * Creates a new <code>GenericPersistenceUnit2_0OptionsTab</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public GenericPersistenceUnit2_0OptionsTab( - PropertyValueModel<JpaOptions2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite parent) { - new GenericPersistenceUnit2_0OptionsComposite(this, parent); - - } - - // ********** Layout ********** - @Override - protected Composite addContainer(Composite parent) { - GridLayout layout = new GridLayout(1, true); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.marginTop = 0; - layout.marginLeft = 0; - layout.marginBottom = 0; - layout.marginRight = 0; - layout.verticalSpacing = 15; - Composite container = this.addPane(parent, layout); - updateGridData(container); - return container; - } - - private void updateGridData(Composite container) { - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } - - // ********** JpaPageComposite implementation ********** - - public String getHelpID() { - return null; // TODO - Review for JPA 2.0 - } - - public ImageDescriptor getPageImageDescriptor() { - return null; - } - - public String getPageText() { - return JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsTab_title; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/LockingConfigurationComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/LockingConfigurationComposite.java deleted file mode 100644 index afc52a4de8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/LockingConfigurationComposite.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * LockingConfigurationComposite - */ -public class LockingConfigurationComposite extends Pane<JpaOptions2_0> -{ - /** - * Creates a new <code>LockingConfigurationComposite</code>. - * - * @param parentController - * The parent container of this one - * @param parent - * The parent container - */ - public LockingConfigurationComposite( - Pane<? extends JpaOptions2_0> parentComposite, - Composite parent) { - - super(parentComposite, parent); - } - - @Override - protected void initializeLayout(Composite parent) { - this.addLockTimeoutCombo(parent); - } - - private void addLockTimeoutCombo(Composite parent) { - new IntegerCombo<JpaOptions2_0>(this, parent) { - - @Override - protected String getLabelText() { - return JptUiPersistence2_0Messages.LockingConfigurationComposite_lockTimeoutLabel; - } - - @Override - protected String getHelpId() { - return null; // TODO - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<JpaOptions2_0, Integer>(this.getSubjectHolder()) { - @Override - protected Integer buildValue_() { - return this.subject.getDefaultLockTimeout(); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<JpaOptions2_0, Integer>(this.getSubjectHolder(), JpaOptions2_0.LOCK_TIMEOUT_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getLockTimeout(); - } - - @Override - protected void setValue_(Integer value) { - this.subject.setLockTimeout(value); - } - }; - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/QueryConfigurationComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/QueryConfigurationComposite.java deleted file mode 100644 index 2707d978ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/QueryConfigurationComposite.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * QueryConfigurationComposite - */ -public class QueryConfigurationComposite extends Pane<JpaOptions2_0> -{ - /** - * Creates a new <code>QueryConfigurationComposite</code>. - * - * @param parentController - * The parent container of this one - * @param parent - * The parent container - */ - public QueryConfigurationComposite( - Pane<? extends JpaOptions2_0> parentComposite, - Composite parent) { - - super(parentComposite, parent); - } - - @Override - protected void initializeLayout(Composite parent) { - this.addQueryTimeoutCombo(parent); - } - - private void addQueryTimeoutCombo(Composite parent) { - new IntegerCombo<JpaOptions2_0>(this, parent) { - - @Override - protected String getLabelText() { - return JptUiPersistence2_0Messages.QueryConfigurationComposite_queryTimeoutLabel; - } - - @Override - protected String getHelpId() { - return null; // TODO - } - - @Override - protected PropertyValueModel<Integer> buildDefaultHolder() { - return new PropertyAspectAdapter<JpaOptions2_0, Integer>(this.getSubjectHolder()) { - @Override - protected Integer buildValue_() { - return this.subject.getDefaultQueryTimeout(); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<JpaOptions2_0, Integer>(this.getSubjectHolder(), JpaOptions2_0.QUERY_TIMEOUT_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getQueryTimeout(); - } - - @Override - protected void setValue_(Integer value) { - this.subject.setQueryTimeout(value); - } - }; - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/SharedCacheModeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/SharedCacheModeComposite.java deleted file mode 100644 index 575b731e44..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/SharedCacheModeComposite.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * SharedCacheModeComposite - */ -public class SharedCacheModeComposite extends Pane<PersistenceUnit2_0> -{ - /** - * Creates a new <code>SharedCacheModeComposite</code>. - * - * @param parentController - * The parent container of this one - * @param parent - * The parent container - */ - public SharedCacheModeComposite( - Pane<?> parentPane, - PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite parent) { - - this.addLabeledComposite( - parent, - JptUiPersistence2_0Messages.SharedCacheModeComposite_sharedCacheModeLabel, - this.addSharedCacheModeCombo(parent), - null // TODO - ); - } - - private EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode> addSharedCacheModeCombo(Composite parent) { - - return new EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode>(this, this.getSubjectHolder(), parent) { - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(PersistenceUnit2_0.SPECIFIED_SHARED_CACHE_MODE_PROPERTY); - } - - @Override - protected SharedCacheMode[] getChoices() { - return SharedCacheMode.values(); - } - - @Override - protected boolean sortChoices() { - return false; - } - - @Override - protected SharedCacheMode getDefaultValue() { - return this.getSubject().getDefaultSharedCacheMode(); - } - - @Override - protected String displayString(SharedCacheMode value) { - return this.buildDisplayString(JptUiPersistence2_0Messages.class, SharedCacheModeComposite.this, value); - } - - @Override - protected SharedCacheMode getValue() { - return this.getSubject().getSpecifiedSharedCacheMode(); - } - - @Override - protected void setValue(SharedCacheMode value) { - this.getSubject().setSpecifiedSharedCacheMode(value); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/ValidationConfigurationComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/ValidationConfigurationComposite.java deleted file mode 100644 index f6f6fce40f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/ValidationConfigurationComposite.java +++ /dev/null @@ -1,385 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import java.util.ListIterator; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.ui.progress.IProgressService; - -/** - * ValidationConfigurationComposite - */ -public class ValidationConfigurationComposite extends Pane<JpaOptions2_0> -{ - /** - * Creates a new <code>ValidationGroupComposite</code>. - * - * @param parentController - * The parent container of this one - * @param parent - * The parent container - */ - public ValidationConfigurationComposite( - Pane<? extends JpaOptions2_0> parentComposite, - Composite parent) { - - super(parentComposite, parent); - } - - @Override - protected void initializeLayout(Composite parent) { - - // SharedCacheMode - new SharedCacheModeComposite(this, this.buildPersistenceUnit2_0Holder(), parent); - - // ValidationMode - new ValidationModeComposite(this, this.buildPersistenceUnit2_0Holder(), parent); - - // ValidationGroupPrePersist - this.addGroupPrePersistListPane(parent); - - // ValidationGroupPreUpdate - this.addGroupPreUpdateListPane(parent); - - // ValidationGroupPreRemove - this.addGroupPreRemoveListPane(parent); - } - - // ********** ValidationGroupPrePersists ********** - - private void addGroupPrePersistListPane(Composite parent) { - - this.addLabeledComposite(parent, - JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPrePersistLabel, - this.addPrePersistListPane(parent), - null // TODO Help - ); - } - - private AddRemoveListPane<JpaOptions2_0> addPrePersistListPane(Composite parent) { - - // List pane - AddRemoveListPane<JpaOptions2_0> listPane = new AddRemoveListPane<JpaOptions2_0>( - this, - parent, - this.buildPrePersistAdapter(), - this.buildPrePersistListHolder(), - this.buildSelectedItemHolder(), - this.buildLabelProvider() - ) - { - @Override - protected void initializeTable(Table table) { - super.initializeTable(table); - - Composite container = table.getParent(); - GridData gridData = (GridData) container.getLayoutData(); - gridData.heightHint = 75; - } - }; - return listPane; - } - - private Adapter buildPrePersistAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addPrePersistClass(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeValidationGroupPrePersist((String) item); - } - } - }; - } - - private ListValueModel<String> buildPrePersistListHolder() { - return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_PERSIST_LIST) { - @Override - protected ListIterator<String> listIterator_() { - return subject.validationGroupPrePersists(); - } - - @Override - protected int size_() { - return subject.validationGroupPrePersistsSize(); - } - }; - } - - private void addPrePersistClass(ObjectListSelectionModel listSelectionModel) { - - IType type = this.chooseType(); - - if (type != null) { - String className = type.getFullyQualifiedName('$'); - if( ! this.getSubject().validationGroupPrePersistExists(className)) { - - String classRef = this.getSubject().addValidationGroupPrePersist(className); - listSelectionModel.setSelectedValue(classRef); - } - } - } - - // ********** ValidationGroupPreUpdates ********** - - private void addGroupPreUpdateListPane(Composite parent) { - - this.addLabeledComposite(parent, - JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreUpdateLabel, - this.addPreUpdateListPane(parent), - null // TODO Help - ); - } - - private AddRemoveListPane<JpaOptions2_0> addPreUpdateListPane(Composite parent) { - - // List pane - AddRemoveListPane<JpaOptions2_0> listPane = new AddRemoveListPane<JpaOptions2_0>( - this, - parent, - this.buildPreUpdateAdapter(), - this.buildPreUpdateListHolder(), - this.buildSelectedItemHolder(), - this.buildLabelProvider() - ) - { - @Override - protected void initializeTable(Table table) { - super.initializeTable(table); - - Composite container = table.getParent(); - GridData gridData = (GridData) container.getLayoutData(); - gridData.heightHint = 75; - } - }; - return listPane; - } - - private Adapter buildPreUpdateAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addPreUpdateClass(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeValidationGroupPreUpdate((String) item); - } - } - }; - } - - private ListValueModel<String> buildPreUpdateListHolder() { - return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_UPDATE_LIST) { - @Override - protected ListIterator<String> listIterator_() { - return subject.validationGroupPreUpdates(); - } - - @Override - protected int size_() { - return subject.validationGroupPreUpdatesSize(); - } - }; - } - - private void addPreUpdateClass(ObjectListSelectionModel listSelectionModel) { - - IType type = this.chooseType(); - - if (type != null) { - String className = type.getFullyQualifiedName('$'); - if( ! this.getSubject().validationGroupPreUpdateExists(className)) { - - String classRef = this.getSubject().addValidationGroupPreUpdate(className); - listSelectionModel.setSelectedValue(classRef); - } - } - } - - // ********** ValidationGroupPreRemoves ********** - - private void addGroupPreRemoveListPane(Composite parent) { - - this.addLabeledComposite(parent, - JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreRemoveLabel, - this.addPreRemoveListPane(parent), - null // TODO Help - ); - } - - private AddRemoveListPane<JpaOptions2_0> addPreRemoveListPane(Composite parent) { - - // List pane - AddRemoveListPane<JpaOptions2_0> listPane = new AddRemoveListPane<JpaOptions2_0>( - this, - parent, - this.buildPreRemoveAdapter(), - this.buildPreRemoveListHolder(), - this.buildSelectedItemHolder(), - this.buildLabelProvider() - ) - { - @Override - protected void initializeTable(Table table) { - super.initializeTable(table); - - Composite container = table.getParent(); - GridData gridData = (GridData) container.getLayoutData(); - gridData.heightHint = 75; - } - }; - return listPane; - } - - private Adapter buildPreRemoveAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addPreRemoveClass(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeValidationGroupPreRemove((String) item); - } - } - }; - } - - private ListValueModel<String> buildPreRemoveListHolder() { - return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_REMOVE_LIST) { - @Override - protected ListIterator<String> listIterator_() { - return subject.validationGroupPreRemoves(); - } - - @Override - protected int size_() { - return subject.validationGroupPreRemovesSize(); - } - }; - } - - private void addPreRemoveClass(ObjectListSelectionModel listSelectionModel) { - - IType type = this.chooseType(); - - if (type != null) { - String className = type.getFullyQualifiedName('$'); - if( ! this.getSubject().validationGroupPreRemoveExists(className)) { - - String classRef = this.getSubject().addValidationGroupPreRemove(className); - listSelectionModel.setSelectedValue(classRef); - } - } - } - - - // ********** Private methods ********** - - private PropertyValueModel<PersistenceUnit2_0> buildPersistenceUnit2_0Holder() { - return new PropertyAspectAdapter<JpaOptions2_0, PersistenceUnit2_0>(this.getSubjectHolder()) { - @Override - protected PersistenceUnit2_0 buildValue_() { - return (PersistenceUnit2_0) this.subject.getPersistenceUnit(); - } - }; - } - - private ILabelProvider buildLabelProvider() { - return new LabelProvider() { - - @Override - public String getText(Object element) { - String name = (String) element; - - if (name == null) { - name = JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsTab_noName; - } - return name; - } - }; - } - - /** - * Prompts the user the Open Type dialog. - * - * @return Either the selected type or <code>null</code> if the user - * canceled the dialog - */ - private IType chooseType() { - IJavaProject javaProject = this.getSubject().getJpaProject().getJavaProject(); - IJavaElement[] elements = new IJavaElement[] { javaProject }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements); - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - SelectionDialog typeSelectionDialog; - - try { - typeSelectionDialog = JavaUI.createTypeDialog( - getShell(), - service, - scope, - IJavaElementSearchConstants.CONSIDER_CLASSES, - false, - "" - ); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - return null; - } - - typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle); - typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage); - - if (typeSelectionDialog.open() == Window.OK) { - return (IType) typeSelectionDialog.getResult()[0]; - } - - return null; - } - - private WritablePropertyValueModel<String> buildSelectedItemHolder() { - return new SimplePropertyValueModel<String>(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/ValidationModeComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/ValidationModeComposite.java deleted file mode 100644 index c7df80240c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/options/ValidationModeComposite.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.jpa2.persistence.options; - -import java.util.Collection; - -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.ValidationMode; -import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages; -import org.eclipse.swt.widgets.Composite; - -/** - * ValidationModeComposite - */ -public class ValidationModeComposite extends Pane<PersistenceUnit2_0> -{ - /** - * Creates a new <code>ValidationModeComposite</code>. - * - * @param parentController - * The parent container of this one - * @param parent - * The parent container - */ - public ValidationModeComposite( - Pane<?> parentPane, - PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite parent) { - - this.addLabeledComposite( - parent, - JptUiPersistence2_0Messages.ValidationModeComposite_validationModeLabel, - this.addValidationModeCombo(parent), - null // TODO - ); - } - - private EnumFormComboViewer<PersistenceUnit2_0, ValidationMode> addValidationModeCombo(Composite parent) { - - return new EnumFormComboViewer<PersistenceUnit2_0, ValidationMode>(this, this.getSubjectHolder(), parent) { - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(PersistenceUnit2_0.SPECIFIED_VALIDATION_MODE_PROPERTY); - } - - @Override - protected ValidationMode[] getChoices() { - return ValidationMode.values(); - } - - @Override - protected boolean sortChoices() { - return false; - } - - @Override - protected ValidationMode getDefaultValue() { - return this.getSubject().getDefaultValidationMode(); - } - - @Override - protected String displayString(ValidationMode value) { - return this.buildDisplayString(JptUiPersistence2_0Messages.class, ValidationModeComposite.this, value); - } - - @Override - protected ValidationMode getValue() { - return this.getSubject().getSpecifiedValidationMode(); - } - - @Override - protected void setValue(ValidationMode value) { - this.getSubject().setSpecifiedValidationMode(value); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/platform/generic/Generic2_0JpaPlatformUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/platform/generic/Generic2_0JpaPlatformUiFactory.java deleted file mode 100644 index c18b25f18c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/platform/generic/Generic2_0JpaPlatformUiFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.jpa2.platform.generic; - -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiFactory; -import org.eclipse.jpt.jpa.ui.internal.jpa2.Generic2_0JpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.GenericJpaPlatformUi; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.GenericNavigatorProvider; - -public class Generic2_0JpaPlatformUiFactory implements JpaPlatformUiFactory -{ - - /** - * Zero arg constructor for extension point - */ - public Generic2_0JpaPlatformUiFactory() { - super(); - } - - public JpaPlatformUi buildJpaPlatformUi() { - return new GenericJpaPlatformUi( - new GenericNavigatorProvider(), - Generic2_0JpaPlatformUiProvider.instance() - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/listeners/SWTConnectionListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/listeners/SWTConnectionListenerWrapper.java deleted file mode 100644 index 9368bf286f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/listeners/SWTConnectionListenerWrapper.java +++ /dev/null @@ -1,348 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.listeners; - -import org.eclipse.jpt.jpa.db.Catalog; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.ConnectionListener; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.ForeignKey; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Sequence; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.swt.widgets.Display; - -/** - * Wrap another connection listener and forward events to it on the SWT - * UI thread, asynchronously if necessary. - */ -public class SWTConnectionListenerWrapper - implements ConnectionListener -{ - - private final ConnectionListener listener; - - public SWTConnectionListenerWrapper(ConnectionListener listener) { - super(); - if (listener == null) { - throw new NullPointerException(); - } - this.listener = listener; - } - - public void opened(ConnectionProfile profile) { - if (this.isExecutingOnUIThread()) { - this.opened_(profile); - } else { - this.executeOnUIThread(this.buildOpenedRunnable(profile)); - } - } - - public void modified(ConnectionProfile profile) { - if (this.isExecutingOnUIThread()) { - this.modified_(profile); - } else { - this.executeOnUIThread(this.buildModifiedRunnable(profile)); - } - } - - public boolean okToClose(ConnectionProfile profile) { - if (this.isExecutingOnUIThread()) { - return this.okToClose_(profile); - } - this.executeOnUIThread(this.buildOkToCloseRunnable(profile)); - return true; - } - - public void aboutToClose(ConnectionProfile profile) { - if (this.isExecutingOnUIThread()) { - this.aboutToClose_(profile); - } else { - this.executeOnUIThread(this.buildAboutToCloseRunnable(profile)); - } - } - - public void closed(ConnectionProfile profile) { - if (this.isExecutingOnUIThread()) { - this.closed_(profile); - } else { - this.executeOnUIThread(this.buildClosedRunnable(profile)); - } - } - - public void databaseChanged(ConnectionProfile profile, Database database) { - if (this.isExecutingOnUIThread()) { - this.databaseChanged_(profile, database); - } else { - this.executeOnUIThread(this.buildDatabaseChangedRunnable(profile, database)); - } - } - - public void catalogChanged(ConnectionProfile profile, Catalog catalog) { - if (this.isExecutingOnUIThread()) { - this.catalogChanged_(profile, catalog); - } else { - this.executeOnUIThread(this.buildCatalogChangedRunnable(profile, catalog)); - } - } - - public void schemaChanged(ConnectionProfile profile, Schema schema) { - if (this.isExecutingOnUIThread()) { - this.schemaChanged_(profile, schema); - } else { - this.executeOnUIThread(this.buildSchemaChangedRunnable(profile, schema)); - } - } - - public void sequenceChanged(ConnectionProfile profile, Sequence sequence) { - if (this.isExecutingOnUIThread()) { - this.sequenceChanged_(profile, sequence); - } else { - this.executeOnUIThread(this.buildSequenceChangedRunnable(profile, sequence)); - } - } - - public void tableChanged(ConnectionProfile profile, Table table) { - if (this.isExecutingOnUIThread()) { - this.tableChanged_(profile, table); - } else { - this.executeOnUIThread(this.buildTableChangedRunnable(profile, table)); - } - } - - public void columnChanged(ConnectionProfile profile, Column column) { - if (this.isExecutingOnUIThread()) { - this.columnChanged_(profile, column); - } else { - this.executeOnUIThread(this.buildColumnChangedRunnable(profile, column)); - } - } - - public void foreignKeyChanged(ConnectionProfile profile, ForeignKey foreignKey) { - if (this.isExecutingOnUIThread()) { - this.foreignKeyChanged_(profile, foreignKey); - } else { - this.executeOnUIThread(this.buildForeignKeyChangedRunnable(profile, foreignKey)); - } - } - - private Runnable buildOpenedRunnable(final ConnectionProfile profile) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.opened_(profile); - } - @Override - public String toString() { - return "opened runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildModifiedRunnable(final ConnectionProfile profile) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.modified_(profile); - } - @Override - public String toString() { - return "modified runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildOkToCloseRunnable(final ConnectionProfile profile) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.okToClose_(profile); - } - @Override - public String toString() { - return "OK to close runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildAboutToCloseRunnable(final ConnectionProfile profile) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.aboutToClose_(profile); - } - @Override - public String toString() { - return "about to close runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildClosedRunnable(final ConnectionProfile profile) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.closed_(profile); - } - @Override - public String toString() { - return "closed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildDatabaseChangedRunnable(final ConnectionProfile profile, final Database database) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.databaseChanged_(profile, database); - } - @Override - public String toString() { - return "database changed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildCatalogChangedRunnable(final ConnectionProfile profile, final Catalog catalog) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.catalogChanged_(profile, catalog); - } - @Override - public String toString() { - return "catalog changed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildSchemaChangedRunnable(final ConnectionProfile profile, final Schema schema) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.schemaChanged_(profile, schema); - } - @Override - public String toString() { - return "schema changed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildSequenceChangedRunnable(final ConnectionProfile profile, final Sequence sequence) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.sequenceChanged_(profile, sequence); - } - @Override - public String toString() { - return "sequence changed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildTableChangedRunnable(final ConnectionProfile profile, final Table table) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.tableChanged_(profile, table); - } - @Override - public String toString() { - return "table changed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildColumnChangedRunnable(final ConnectionProfile profile, final Column column) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.columnChanged_(profile, column); - } - @Override - public String toString() { - return "column changed runnable"; //$NON-NLS-1$ - } - }; - } - - private Runnable buildForeignKeyChangedRunnable(final ConnectionProfile profile, final ForeignKey foreignKey) { - return new Runnable() { - public void run() { - SWTConnectionListenerWrapper.this.foreignKeyChanged_(profile, foreignKey); - } - @Override - public String toString() { - return "foreign key changed runnable"; //$NON-NLS-1$ - } - }; - } - - private boolean isExecutingOnUIThread() { - return Display.getCurrent() != null; - } - - /** - * {@link Display#asyncExec(Runnable)} seems to work OK; - * but using {@link Display#syncExec(Runnable)} can somtimes make things - * more predictable when debugging, at the risk of deadlocks. - */ - private void executeOnUIThread(Runnable r) { - Display.getDefault().asyncExec(r); -// Display.getDefault().syncExec(r); - } - - void opened_(ConnectionProfile profile) { - this.listener.opened(profile); - } - - void modified_(ConnectionProfile profile) { - this.listener.modified(profile); - } - - boolean okToClose_(ConnectionProfile profile) { - return this.listener.okToClose(profile); - } - - void aboutToClose_(ConnectionProfile profile) { - this.listener.aboutToClose(profile); - } - - void closed_(ConnectionProfile profile) { - this.listener.closed(profile); - } - - void databaseChanged_(ConnectionProfile profile, Database database) { - this.listener.databaseChanged(profile, database); - } - - void catalogChanged_(ConnectionProfile profile, Catalog catalog) { - this.listener.catalogChanged(profile, catalog); - } - - void schemaChanged_(ConnectionProfile profile, Schema schema) { - this.listener.schemaChanged(profile, schema); - } - - void sequenceChanged_(ConnectionProfile profile, Sequence sequence) { - this.listener.sequenceChanged(profile, sequence); - } - - void tableChanged_(ConnectionProfile profile, Table table) { - this.listener.tableChanged(profile, table); - } - - void columnChanged_(ConnectionProfile profile, Column column) { - this.listener.columnChanged(profile, column); - } - - void foreignKeyChanged_(ConnectionProfile profile, ForeignKey foreignKey) { - this.listener.foreignKeyChanged(profile, foreignKey); - } - - @Override - public String toString() { - return "SWT(" + this.listener.toString() + ')'; //$NON-NLS-1$ - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/MapAsContribution.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/MapAsContribution.java deleted file mode 100644 index 054e7ab34b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/MapAsContribution.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.menus; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.internal.jface.ImageImageDescriptor; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.ui.ISources; -import org.eclipse.ui.actions.CompoundContributionItem; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.menus.CommandContributionItem; -import org.eclipse.ui.menus.CommandContributionItemParameter; -import org.eclipse.ui.menus.IWorkbenchContribution; -import org.eclipse.ui.services.IServiceLocator; -import com.ibm.icu.text.Collator; - -/** - * This menu contribution is responsible to populate the Map As menu with the - * registered mapping types defined in the <code>JptPlatformUi</code>. - * - * @see JpaPlatform - * @see JpaPlatformUi - * - * @version 2.0 - * @since 2.0 - */ -@SuppressWarnings("nls") -public abstract class MapAsContribution<T extends JpaStructureNode> - extends CompoundContributionItem - implements IWorkbenchContribution -{ - /** - * Keeps track of the <code>IServiceLocator</code> which is used to retrieve - * various services required for invoking the <code>PersistentAttributeMapAsHandler</code>. - */ - private IServiceLocator serviceLocator; - - - /** - * Creates a new <code>PersistentAttributeMapAsContribution</code>. - */ - public MapAsContribution() { - super(); - } - - - public void initialize(IServiceLocator serviceLocator) { - this.serviceLocator = serviceLocator; - } - - @Override - protected IContributionItem[] getContributionItems() { - // Retrieve the selection from the handler service - // which should be an IStructuredSelection of JpaStructureNodes - IHandlerService handlerService = - (IHandlerService) this.serviceLocator.getService(IHandlerService.class); - IStructuredSelection currentSelection = - (IStructuredSelection) handlerService.getCurrentState().getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME); - - // Assume that all nodes are in the same project (which is very safe) - // and retrieve the mapping UI providers just from the first item - T node = (T) currentSelection.getFirstElement(); - - return - ArrayTools.array( - new TransformationIterator<MappingUiDefinition<T, ?>, IContributionItem>(mappingUiDefinitions(node)) { - @Override - protected IContributionItem transform(MappingUiDefinition<T, ?> next) { - return createContributionItem(next); - } - }, - new IContributionItem[0]); - } - - - protected Comparator<MappingUiDefinition<T, ?>> getDefinitionsComparator() { - return new Comparator<MappingUiDefinition<T, ?>>() { - public int compare(MappingUiDefinition<T, ?> item1, MappingUiDefinition<T, ?> item2) { - String displayString1 = item1.getLabel(); - String displayString2 = item2.getLabel(); - return Collator.getInstance().compare(displayString1, displayString2); - } - }; - } - - /** - * Retrieves the registered {@link MappingUiDefinition}s from the given node, - * using its {@link JpaPlatformUi}. - * - * @param node A test node to determine the {@link JpaPlatformUi} and type - * of providers to return - * @return The list of registered {@link MappingUiDefinition}s - */ - protected <U extends T> Iterator<? extends MappingUiDefinition<T, ?>> mappingUiDefinitions(final T node) { - JpaPlatform jpaPlatform = node.getJpaProject().getJpaPlatform(); - JpaPlatformUi jpaPlatformUi = JptJpaUiPlugin.instance().getJpaPlatformUi(jpaPlatform); - - Iterator<? extends MappingUiDefinition<T, ?>> sortedMappingUiDefinitions = - CollectionTools.sort( - new FilteringIterator<MappingUiDefinition<T, ?>>( - mappingUiDefinitions(jpaPlatformUi, node.getResourceType())) { - @Override - protected boolean accept(MappingUiDefinition<T, ?> o) { - return o.isEnabledFor(node); - } - }, - getDefinitionsComparator()); - - DefaultMappingUiDefinition<T, ?> defaultDefinition = getDefaultMappingUiDefinition(jpaPlatformUi, node); - if (defaultDefinition != null) { - return new CompositeIterator<MappingUiDefinition<T, ?>>(defaultDefinition, sortedMappingUiDefinitions); - } - return sortedMappingUiDefinitions; - } - - /** - * Retrieves the registered {@link MappingUiDefinition}s from the given - * {@link JpaPlatformUi} and {@link JpaStructureNode} (to determine type of - * mapping providers to retrieve). - * - * @param jpaPlatformUi The active {@link JpaPlatformUi} from where the - * provider can be retrieved - * @param node A test node to determine type of providers to return - * @return The list of registered {@link MappingUiDefinition}s - */ - protected abstract Iterator<? extends MappingUiDefinition<T, ?>> - mappingUiDefinitions(JpaPlatformUi platformUi, JptResourceType resourceType); - - /** - * Creates the default provider responsible for clearing the mapping type. - * If not default provider, then return null - * - * @return A provider that acts as a default mapping provider - */ - protected abstract DefaultMappingUiDefinition<T, ?> getDefaultMappingUiDefinition(JpaPlatformUi platformUi, T node); - - protected IContributionItem createContributionItem(MappingUiDefinition<T, ?> mappingUiProvider) { - return new CommandContributionItem(createParameter(mappingUiProvider)); - } - - protected CommandContributionItemParameter createParameter(MappingUiDefinition<T, ?> mappingUiDefinition) { - CommandContributionItemParameter parameter = - new CommandContributionItemParameter( - this.serviceLocator, - createCommandContributionItemId(mappingUiDefinition), - getCommandId(), - CommandContributionItem.STYLE_CHECK); - parameter.label = mappingUiDefinition.getLabel(); - Map<String, String> parameters = new HashMap<String, String>(); - parameters.put(getCommandParameterId(), mappingUiDefinition.getKey()); - parameter.parameters = parameters; - parameter.icon = new ImageImageDescriptor(mappingUiDefinition.getImage()); - parameter.visibleEnabled = true; - return parameter; - } - - /** - * Retrieves the unique identifier of the command that will be invoked for - * changing the mapping type of the selected nodes. - * - * @return The unique identifier of the "map as" command - */ - protected abstract String getCommandId(); - - /** - * Retrieves the unique identifier of the mapping key command parameter that - * will be used for the new mapping type of the selected nodes. - * - * @return The unique identifier of the "map as" command parameter - */ - protected abstract String getCommandParameterId(); - - /** - * Returns an id for a {@link CommandContributionItem} in the form of - * "<commandId>.<mappingKey>" - * (for example "org.eclipse.jpt.jpa.core.ui.persistentTypeMapAs.entity") - */ - protected String createCommandContributionItemId(MappingUiDefinition<T, ?> mappingUiDefinition) { - return getCommandId() + "." + mappingUiDefinition.getKey(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/PersistentAttributeMapAsContribution.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/PersistentAttributeMapAsContribution.java deleted file mode 100644 index 45e1c6393b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/PersistentAttributeMapAsContribution.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.menus; - -import java.util.Iterator; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.commands.PersistentAttributeMapAsHandler; -import org.eclipse.ui.menus.CommandContributionItemParameter; - -/** - * This menu contribution is responsible to populate the Map As menu with the - * registered attribute mapping types defined in the <code>JptPlatformUi</code> - * for <code>PersistentAttribute</code> objects. - * - * @see PersistentAttributeMapAsHandler - * @see PersistentAttribute - * - * @version 2.2 - * @since 2.0 - */ -public class PersistentAttributeMapAsContribution - extends MapAsContribution<ReadOnlyPersistentAttribute> -{ - /** - * Creates a new <code>PersistentAttributeMapAsContribution</code>. - */ - public PersistentAttributeMapAsContribution() { - super(); - } - - @Override - protected String getCommandId() { - return PersistentAttributeMapAsHandler.COMMAND_ID; - } - - @Override - protected String getCommandParameterId() { - return PersistentAttributeMapAsHandler.SPECIFIED_MAPPING_COMMAND_PARAMETER_ID; - } - - @Override - protected CommandContributionItemParameter createParameter(MappingUiDefinition<ReadOnlyPersistentAttribute, ?> mappingUiProvider) { - CommandContributionItemParameter parameter = super.createParameter(mappingUiProvider); - String defaultKey = null; - if (mappingUiProvider instanceof DefaultMappingUiDefinition<?, ?>) { - defaultKey = ((DefaultMappingUiDefinition<? extends PersistentAttribute, ?>) mappingUiProvider).getDefaultKey(); - } - parameter.parameters.put(PersistentAttributeMapAsHandler.DEFAULT_MAPPING_COMMAND_PARAMETER_ID, defaultKey); - return parameter; - } - - @Override - protected Iterator<? extends MappingUiDefinition<ReadOnlyPersistentAttribute, ?>> mappingUiDefinitions( - JpaPlatformUi jpaPlatformUi, JptResourceType resourceType) { - - return jpaPlatformUi.attributeMappingUiDefinitions(resourceType); - } - - @Override - protected DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ?> getDefaultMappingUiDefinition( - JpaPlatformUi jpaPlatformUi, ReadOnlyPersistentAttribute node) { - - return getDefaultMappingUiDefinition( - jpaPlatformUi, - ((PersistentAttribute) node).getDefaultMappingKey(), - node.getResourceType()); - } - - protected DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ?> getDefaultMappingUiDefinition( - JpaPlatformUi jpaPlatformUi, String defaultMappingKey, JptResourceType resourceType) { - - return jpaPlatformUi.getDefaultAttributeMappingUiDefinition(resourceType, defaultMappingKey); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/PersistentTypeMapAsContribution.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/PersistentTypeMapAsContribution.java deleted file mode 100644 index ac878eb934..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/menus/PersistentTypeMapAsContribution.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.menus; - -import java.util.Iterator; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.commands.PersistentTypeMapAsHandler; - -/** - * This menu contribution is responsible to populate the Map As menu with the - * registered mapping types defined in the <code>JptPlatformUi</code> for - * <code>PersistentType</code> objects. - * - * @see JpaPlatform - * @see JpaPlatformUi - * @see PersistentType - */ -public class PersistentTypeMapAsContribution - extends MapAsContribution<PersistentType> -{ - /** - * Creates a new <code>PersistentTypeMapAsContribution</code>. - */ - public PersistentTypeMapAsContribution() { - super(); - } - - - @Override - protected String getCommandId() { - return PersistentTypeMapAsHandler.COMMAND_ID; - } - - @Override - protected String getCommandParameterId() { - return PersistentTypeMapAsHandler.COMMAND_PARAMETER_ID; - } - - @Override - protected Iterator<? extends MappingUiDefinition<PersistentType, ?>> mappingUiDefinitions( - JpaPlatformUi jpaPlatformUi, JptResourceType resourceType) { - - return jpaPlatformUi.typeMappingUiDefinitions(resourceType); - } - - @Override - protected DefaultMappingUiDefinition<PersistentType, ?> getDefaultMappingUiDefinition( - JpaPlatformUi jpaPlatformUi, PersistentType node) { - - return jpaPlatformUi.getDefaultTypeMappingUiDefinition(node.getResourceType()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorActionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorActionProvider.java deleted file mode 100644 index 17f73794a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorActionProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.navigator; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.ui.internal.actions.OpenJpaResourceAction; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.navigator.CommonActionProvider; -import org.eclipse.ui.navigator.ICommonActionConstants; -import org.eclipse.ui.navigator.ICommonActionExtensionSite; -import org.eclipse.ui.navigator.ICommonMenuConstants; - -public class JpaNavigatorActionProvider extends CommonActionProvider -{ - private OpenJpaResourceAction openAction; - - public JpaNavigatorActionProvider() { - super(); - } - - public void init(ICommonActionExtensionSite aConfig) { - openAction = new OpenJpaResourceAction(); - } - - public void setContext(ActionContext aContext) { - if (aContext != null && aContext.getSelection() instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) aContext.getSelection(); - openAction.selectionChanged(selection); - } - - super.setContext(aContext); - } - - public void fillActionBars(IActionBars theActionBars) { - if (openAction.isEnabled()) { - theActionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openAction); - } - } - - public void fillContextMenu(IMenuManager aMenu) { - if (getContext() == null || getContext().getSelection().isEmpty()) { - return; - } - - if (openAction.isEnabled()) { - aMenu.insertAfter(ICommonMenuConstants.GROUP_OPEN, openAction); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentAndLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentAndLabelProvider.java deleted file mode 100644 index 9075967581..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentAndLabelProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.navigator; - -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; - -public class JpaNavigatorContentAndLabelProvider extends DelegatingTreeContentAndLabelProvider -{ - public JpaNavigatorContentAndLabelProvider() { - super(new JpaNavigatorTreeItemContentProviderFactory(), new JpaNavigatorItemLabelProviderFactory()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java deleted file mode 100644 index 12e0ae7fc6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.navigator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.navigator.ICommonContentExtensionSite; -import org.eclipse.ui.navigator.ICommonContentProvider; -import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; -import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent; - -/** - * This extension of navigator content provider delegates to the platform UI - * (see the org.eclipse.jpt.jpa.ui.jpaPlatform extension point) for navigator content. - * - * If there is a platform UI for the given project, this content provider will - * provide a root "JPA Content" node (child of the project), otherwise there - * will be no content. For children of the "JPA Content" node (or for any other - * sub-node), this provider will delegate to the content provider returned by the - * platform UI implementation. - */ -public class JpaNavigatorContentProvider - implements ICommonContentProvider { - - private JpaNavigatorContentAndLabelProvider delegate; - - private IFacetedProjectListener facetListener; - - private StructuredViewer viewer; - - - public JpaNavigatorContentProvider() { - super(); - facetListener = new FacetListener(); - FacetedProjectFramework.addListener( - facetListener, - IFacetedProjectEvent.Type.POST_INSTALL, - IFacetedProjectEvent.Type.POST_UNINSTALL, - IFacetedProjectEvent.Type.PROJECT_MODIFIED); - } - - - public JpaNavigatorContentAndLabelProvider delegate() { - return delegate; - } - - - // **************** IContentProvider implementation ************************ - - public void dispose() { - FacetedProjectFramework.removeListener(facetListener); - if (delegate != null) { - delegate.dispose(); - } - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (delegate != null) { - delegate.inputChanged(viewer, oldInput, newInput); - } - this.viewer = (StructuredViewer) viewer; - } - - - // **************** IStructuredContentProvider implementation ************** - - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - - // **************** ITreeContentProvider implementation ******************** - - public Object getParent(Object element) { - if (delegate != null) { - return delegate.getParent(element); - } - - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof IAdaptable) { - IProject project = (IProject) ((IAdaptable) element).getAdapter(IProject.class); - - if (project != null) { - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project); - if (jpaProject != null) { - JpaPlatformUi platformUi = JptJpaUiPlugin.instance().getJpaPlatformUi(jpaProject.getJpaPlatform()); - - return platformUi != null; - } - } - } - - if (delegate != null) { - return delegate.hasChildren(element); - } - - return false; - } - - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof IAdaptable) { - IProject project = (IProject) ((IAdaptable) parentElement).getAdapter(IProject.class); - - if (project != null) { - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project); - if (jpaProject != null) { - JpaPlatformUi platformUi = JptJpaUiPlugin.instance().getJpaPlatformUi(jpaProject.getJpaPlatform()); - - if (platformUi != null) { - return new Object[] {jpaProject.getRootContextNode()}; - } - } - } - } - - if (delegate != null) { - return delegate.getChildren(parentElement); - } - - return new Object[0]; - } - - - // **************** IMementoAware implementation *************************** - - public void saveState(IMemento memento) { - // no op - } - - public void restoreState(IMemento memento) { - // no op - } - - - // **************** ICommonContentProvider implementation ****************** - - public void init(ICommonContentExtensionSite config) { - if (delegate == null) { - JpaNavigatorLabelProvider labelProvider = (JpaNavigatorLabelProvider) config.getExtension().getLabelProvider(); - if (labelProvider != null && labelProvider.delegate() != null) { - delegate = labelProvider.delegate(); - } - else { - delegate = new JpaNavigatorContentAndLabelProvider(); - } - } - } - - - // **************** member classes ***************************************** - - private class FacetListener - implements IFacetedProjectListener - { - public void handleEvent(IFacetedProjectEvent event) { - if (event.getType() == IFacetedProjectEvent.Type.PROJECT_MODIFIED) { - refreshViewer(event.getProject().getProject()); - } - else if (event.getType() == IFacetedProjectEvent.Type.POST_INSTALL - || event.getType() == IFacetedProjectEvent.Type.POST_UNINSTALL) { - IProjectFacetActionEvent ipaEvent = (IProjectFacetActionEvent) event; - if (ipaEvent.getProjectFacet().equals(JpaFacet.FACET)) { - refreshViewer(ipaEvent.getProject().getProject()); - } - } - } - - private void refreshViewer(final IProject project) { - if (viewer != null - && viewer.getControl() != null - && !viewer.getControl().isDisposed()) { - // Using job here so that project model update (which also uses - // a job) will complete first - Job refreshJob = new Job("Refresh viewer") { - @Override - protected IStatus run(IProgressMonitor monitor) { - // Using runnable here so that refresh will go on correct thread - viewer.getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - viewer.refresh(project); - } - }); - return Status.OK_STATUS; - } - }; - refreshJob.setRule(project); - refreshJob.schedule(); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java deleted file mode 100644 index 77a06d342f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.navigator; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; - -public class JpaNavigatorItemLabelProviderFactory - implements ItemLabelProviderFactory -{ - /** - * Exactly *one* of these factories is created for each view that utilizes it. - * Therefore, as we delegate to the platform UI for each project, we should - * maintain the same multiplicity. That is, if there is a delegate for each - * platform UI, we should maintain *one* delegate for each view. - * - * Key: platform id, Value: delegate content provider factory - */ - private final Map<String, ItemLabelProviderFactory> delegates; - - - public JpaNavigatorItemLabelProviderFactory() { - super(); - this.delegates = new HashMap<String, ItemLabelProviderFactory>(); - } - - public ItemLabelProvider buildItemLabelProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - ItemLabelProviderFactory delegate = getDelegate(item); - if (delegate != null) { - return delegate.buildItemLabelProvider(item, contentAndLabelProvider); - } - return null; - } - - - private ItemLabelProviderFactory getDelegate(Object element) { - if (! (element instanceof IAdaptable)) { - return null; - } - - JpaContextNode contextNode = (JpaContextNode) ((IAdaptable) element).getAdapter(JpaContextNode.class); - - if (contextNode == null) { - return null; - } - - JpaPlatform platform = contextNode.getJpaProject().getJpaPlatform(); - String platformId = platform.getId(); - if (delegates.containsKey(platformId)) { - return delegates.get(platformId); - } - JpaNavigatorProvider navigatorProvider = JptJpaUiPlugin.instance().getJpaNavigatorProvider(platform); - ItemLabelProviderFactory delegate = null; - if (navigatorProvider != null) { - delegate = navigatorProvider.getItemLabelProviderFactory(); - } - delegates.put(platformId, delegate); - return delegate; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorLabelProvider.java deleted file mode 100644 index 8066e9ff12..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorLabelProvider.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.navigator; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.navigator.ICommonContentExtensionSite; -import org.eclipse.ui.navigator.ICommonLabelProvider; - -/** - * This extension of navigator label provider delegates to the platform UI - * (see the org.eclipse.jpt.jpa.ui.jpaPlatform extension point) for navigator labels. - * - * This label provider provides a label for the root "JPA Content" node provided - * by the content provider (see {@link JpaNavigatorContentProvider}) and delegates - * to the label provider returned by the platform UI implementation for labels - * for children of the "JPA Content" node (or for any other sub-node). - */ -public class JpaNavigatorLabelProvider - extends LabelProvider - implements ICommonLabelProvider { - - private JpaNavigatorContentAndLabelProvider delegate; - - - public JpaNavigatorLabelProvider() { - super(); - } - - - public JpaNavigatorContentAndLabelProvider delegate() { - return delegate; - } - - - // **************** IBaseLabelProvider implementation ********************** - - @Override - public void addListener(ILabelProviderListener listener) { - if (delegate != null) { - delegate.addListener(listener); - } - super.addListener(listener); - } - - @Override - public void removeListener(ILabelProviderListener listener) { - super.removeListener(listener); - if (delegate != null) { - delegate.removeListener(listener); - } - } - - @Override - public boolean isLabelProperty(Object element, String property) { - if (delegate != null) { - return delegate.isLabelProperty(element, property); - } - - return super.isLabelProperty(element, property); - } - - @Override - public void dispose() { - if (delegate != null) { - delegate.dispose(); - } - super.dispose(); - } - - - // **************** ILabelProvider implementation ************************** - - @Override - public Image getImage(Object element) { - if (delegate != null) { - return delegate.getImage(element); - } - - return super.getImage(element); - } - - @Override - public String getText(Object element) { - if (delegate != null) { - return delegate.getText(element); - } - - return super.getText(element); - } - - - // **************** IDescriptionProvider implementation ******************** - - public String getDescription(Object element) { - if (delegate != null) { - return delegate.getDescription(element); - } - - return super.getText(element); - } - - - // **************** IMementoAware implementation *************************** - - public void saveState(IMemento memento) { - // no op - } - - public void restoreState(IMemento memento) { - // no op - } - - - // **************** ICommonLabelProvider implementation ******************** - - public void init(ICommonContentExtensionSite config) { - if (delegate == null) { - JpaNavigatorContentProvider contentProvider = (JpaNavigatorContentProvider) config.getExtension().getContentProvider(); - if (contentProvider != null && contentProvider.delegate() != null) { - delegate = contentProvider.delegate(); - } - else { - delegate = new JpaNavigatorContentAndLabelProvider(); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorTreeItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorTreeItemContentProviderFactory.java deleted file mode 100644 index 604f912622..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorTreeItemContentProviderFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.navigator; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; - -public class JpaNavigatorTreeItemContentProviderFactory - implements TreeItemContentProviderFactory -{ - /** - * Exactly *one* of these factories is created for each view that utilizes it. - * Therefore, as we delegate to the platform UI for each project, we should - * maintain the same multiplicity. That is, if there is a delegate for each - * platform UI, we should maintain *one* delegate for each view. - * - * Key: platform id, Value: delegate content provider factory - */ - private Map<String, TreeItemContentProviderFactory> delegates; - - - public JpaNavigatorTreeItemContentProviderFactory() { - super(); - this.delegates = new HashMap<String, TreeItemContentProviderFactory>(); - } - - public TreeItemContentProvider buildItemContentProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - TreeItemContentProviderFactory delegate = getDelegate(item); - if (delegate != null) { - return delegate.buildItemContentProvider(item, contentAndLabelProvider); - } - return null; - } - - - private TreeItemContentProviderFactory getDelegate(Object element) { - if (! (element instanceof IAdaptable)) { - return null; - } - - JpaContextNode contextNode = (JpaContextNode) ((IAdaptable) element).getAdapter(JpaContextNode.class); - - if (contextNode == null) { - return null; - } - - JpaPlatform platform = contextNode.getJpaProject().getJpaPlatform(); - String platformId = platform.getId(); - if (delegates.containsKey(platformId)) { - return delegates.get(platformId); - } - JpaNavigatorProvider navigatorProvider = JptJpaUiPlugin.instance().getJpaNavigatorProvider(platform); - TreeItemContentProviderFactory delegate = null; - if (navigatorProvider != null) { - delegate = navigatorProvider.getTreeItemContentProviderFactory(); - } - delegates.put(platformId, delegate); - return delegate; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java deleted file mode 100644 index fa852649bc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.persistence; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali persistence editor. - * - * @version 2.0 - * @since 2.0 - */ -public class JptUiPersistenceMessages { - - public static String ArchiveFileSelectionDialog_jarPathHelpLabel; - public static String ArchiveFileSelectionDialog_jarPathLabel; - - public static String PersistenceEditor_page_help; - public static String PersistenceEditor_sourceTab; - - public static String PersistenceUnitClassesComposite_description; - public static String PersistenceUnitClassesComposite_excludeUnlistedMappedClasses; - public static String PersistenceUnitClassesComposite_excludeUnlistedMappedClassesWithDefault; - public static String PersistenceUnitClassesComposite_mappedClassesNoName; - public static String PersistenceUnitClassesComposite_open; - - public static String PersistenceUnitConnectionComposite_connection; - public static String PersistenceUnitConnectionComposite_database; - public static String PersistenceUnitConnectionComposite_general; - - public static String PersistenceUnitConnectionDatabaseComposite_jtaDatasourceName; - public static String PersistenceUnitConnectionDatabaseComposite_nonJtaDatasourceName; - - public static String PersistenceUnitConnectionGeneralComposite_default; - public static String PersistenceUnitConnectionGeneralComposite_jta; - public static String PersistenceUnitConnectionGeneralComposite_resource_local; - public static String PersistenceUnitConnectionGeneralComposite_transactionType; - - public static String PersistenceUnitGeneralComposite_general; - public static String PersistenceUnitGeneralComposite_jarFiles; - public static String PersistenceUnitGeneralComposite_jpaMappingDescriptors; - public static String PersistenceUnitGeneralComposite_jpaMappingDescriptors_description; - public static String PersistenceUnitGeneralComposite_mappedClasses; - public static String PersistenceUnitGeneralComposite_name; - public static String PersistenceUnitGeneralComposite_persistenceProvider; - public static String PersistenceUnitGeneralComposite_description; - - public static String PersistenceUnitJarFilesComposite_noFileName; - public static String PersistenceUnitMappingFilesComposite_jarFileDialog_title; - public static String PersistenceUnitMappingFilesComposite_jarFileDialog_message; - - public static String PersistenceUnitMappingFilesComposite_mappingFileDialog_message; - public static String PersistenceUnitMappingFilesComposite_mappingFileDialog_title; - public static String PersistenceUnitMappingFilesComposite_ormNoName; - - public static String PersistenceUnitPropertiesComposite_nameColumn; - public static String PersistenceUnitPropertiesComposite_properties; - public static String PersistenceUnitPropertiesComposite_properties_description; - public static String PersistenceUnitPropertiesComposite_valueColumn; - - private static final String BUNDLE_NAME = "jpt_ui_persistence"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiPersistenceMessages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiPersistenceMessages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/AbstractPersistenceXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/AbstractPersistenceXmlResourceUiDefinition.java deleted file mode 100644 index 19ff3fffbc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/AbstractPersistenceXmlResourceUiDefinition.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.persistence.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.PersistenceXmlResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.swt.widgets.Composite; - -/** - * All the state in the definition should be "static" (i.e. unchanging once it is initialized). - */ -public abstract class AbstractPersistenceXmlResourceUiDefinition - implements ResourceUiDefinition, PersistenceXmlResourceUiDefinition -{ - - - private final PersistenceXmlUiFactory factory; - - - /** - * zero-argument constructor - */ - protected AbstractPersistenceXmlResourceUiDefinition() { - super(); - this.factory = buildPersistenceXmlUiFactory(); - } - - - protected abstract PersistenceXmlUiFactory buildPersistenceXmlUiFactory(); - - public PersistenceXmlUiFactory getFactory() { - return this.factory; - } - - public ListIterator<JpaPageComposite> buildPersistenceUnitComposites(PropertyValueModel<PersistenceUnit> subjectHolder, Composite parent, WidgetFactory widgetFactory) { - return this.factory.createPersistenceUnitComposites(subjectHolder, parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/ArchiveFileSelectionDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/ArchiveFileSelectionDialog.java deleted file mode 100644 index 8a2717420a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/ArchiveFileSelectionDialog.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.persistence.details; - -import java.util.Collections; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jpt.common.ui.internal.jface.ArchiveFileViewerFilter; -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.navigator.ResourceComparator; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualContainer; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -public class ArchiveFileSelectionDialog - extends ElementTreeSelectionDialog -{ - private final WritablePropertyValueModel<String> jarPathModel; - - private DeploymentPathCalculator pathCalculator; - - - public ArchiveFileSelectionDialog(Shell parent) { - this(parent, new SimpleDeploymentPathCalculator()); - } - - public ArchiveFileSelectionDialog(Shell parent, DeploymentPathCalculator pathCalculator) { - super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - this.pathCalculator = pathCalculator; - setComparator(new ResourceComparator(ResourceComparator.NAME)); - addFilter(new ArchiveFileViewerFilter()); - setValidator(new ArchiveFileSelectionValidator()); - this.jarPathModel = new SimplePropertyValueModel<String>(); - } - - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - - Label helpLabel = new Label(composite, SWT.WRAP); - helpLabel.setText(JptUiPersistenceMessages.ArchiveFileSelectionDialog_jarPathHelpLabel); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = 400; - helpLabel.setLayoutData(gd); - - Composite subComposite = new Composite(composite, SWT.NONE); - subComposite.setLayout(new GridLayout(2, false)); - subComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label jarPathLabel = new Label(subComposite, SWT.NONE); - jarPathLabel.setFont(composite.getFont()); - jarPathLabel.setText(JptUiPersistenceMessages.ArchiveFileSelectionDialog_jarPathLabel); - - Text jarPathText = new Text(subComposite, SWT.BORDER); - jarPathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - SWTTools.bind(jarPathModel, jarPathText); - - return composite; - } - - @Override - protected TreeViewer doCreateTreeViewer(Composite parent, int style) { - TreeViewer treeViewer = super.doCreateTreeViewer(parent, style); - - treeViewer.addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateJarPathModel(event.getSelection()); - } - }); - - return treeViewer; - } - - protected void updateJarPathModel(ISelection selection) { - Object selectedObj = ((IStructuredSelection) selection).getFirstElement(); - if (selectedObj instanceof IFile) { - this.jarPathModel.setValue(calculateDeployPath((IFile) selectedObj)); - } - else { - this.jarPathModel.setValue(""); - } - } - - protected String calculateDeployPath(IFile archiveFile) { - return this.pathCalculator.calculateDeploymentPath(archiveFile); - } - - @Override - protected void computeResult() { - setResult(Collections.singletonList(this.jarPathModel.getValue())); - } - - - private static class ArchiveFileSelectionValidator - implements ISelectionStatusValidator - { - public ArchiveFileSelectionValidator() { - super(); - } - - - public IStatus validate(Object[] selection) { - int nSelected= selection.length; - if (nSelected == 0 || (nSelected > 1)) { - return new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ - } - for (int i= 0; i < selection.length; i++) { - Object curr= selection[i]; - if (curr instanceof IFile) { - return new Status(IStatus.OK, JptJpaUiPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ - } - } - return new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ - } - } - - - public static interface DeploymentPathCalculator - { - String calculateDeploymentPath(IFile file); - } - - - public static class SimpleDeploymentPathCalculator - implements DeploymentPathCalculator - { - public String calculateDeploymentPath(IFile file) { - return file.getName(); - } - } - - - public static class ModuleDeploymentPathCalculator - extends SimpleDeploymentPathCalculator - { - @Override - public String calculateDeploymentPath(IFile file) { - // first look for virtual component that matches this file, returning - // the path to that virtual component - IVirtualComponent vComponent = ComponentCore.createComponent(file.getProject()); - if (vComponent != null) { - IVirtualFolder vFolder = vComponent.getRootFolder(); - IVirtualFile vFile = findVirtualFile(vFolder, file); - if (vFile != null) { - return calculatePersistenceRootRelativePath(vFile); - } - } - - // then default to simple behavior - return super.calculateDeploymentPath(file); - } - - protected IVirtualFile findVirtualFile(IVirtualContainer vContainer, IFile realFile) { - try { - for (IVirtualResource vResource : vContainer.members()) { - if (vResource.getType() == IVirtualResource.FILE) { - IVirtualFile vFile = (IVirtualFile) vResource; - if (realFile.equals(vFile.getUnderlyingFile())) { - return vFile; - } - } - else { - IVirtualFile vFile = findVirtualFile((IVirtualContainer) vResource, realFile); - if (vFile != null) { - return vFile; - } - } - } - } - catch (CoreException ce) { - JptJpaUiPlugin.log(ce); - } - - return null; - } - - protected String calculatePersistenceRootRelativePath(IVirtualFile vFile) { - IProject project = vFile.getProject(); - IPath puRootPath = JptJpaCorePlugin.getJarRuntimeRootPath(project); - - IPath path = vFile.getRuntimePath().makeRelativeTo(puRootPath); - - return path.toString(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitGeneralComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitGeneralComposite.java deleted file mode 100644 index 5c25dab4de..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitGeneralComposite.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - General --------------------------------------------------------------- | - * | ------------------------------------------------- | - * | Name: | I | | - * | ------------------------------------------------- | - * | ------------------------------------------------- | - * | Persistence Provider: | |v| | - * | ------------------------------------------------- | - * | | - * | | - * | - Mapped Classes -------------------------------------------------------- | - * | | - * | Description | - * | | - * | ----------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitMappedClassesComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * | | - * | | - * | - XML Mapping Files ----------------------------------------------------- | - * | | - * | Description | - * | | - * | ----------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitMappingFilesComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitJarFilesComposite - * @see PersistenceUnitMappedClassesComposite - * @see PersistenceUnitMappingFilesComposite - * - * @version 2.0 - * @since 2.0 - */ -public class GenericPersistenceUnitGeneralComposite extends PersistenceUnitGeneralComposite - implements JpaPageComposite -{ - /** - * Creates a new <code>PersistenceUnitGeneralComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public GenericPersistenceUnitGeneralComposite(PropertyValueModel<PersistenceUnit> subjectHolder, - Composite container, - WidgetFactory widgetFactory) { - - super(subjectHolder, container, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - initializeGeneralPane(container); - initializeMappedClassesPane(container); - initializeJPAMappingDescriptorsPane(container); - initializeJarFilesPane(container); - } - - - protected void initializeJPAMappingDescriptorsPane(Composite container) { - - container = addCollapsibleSection( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jpaMappingDescriptors, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jpaMappingDescriptors_description - ); - - updateGridData(container); - updateGridData(container.getParent()); - - new GenericPersistenceUnitMappingFilesComposite(this, container); - } - - protected void initializeJarFilesPane(Composite container) { - - container = addCollapsibleSection( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jarFiles - ); - - updateGridData(container); - updateGridData(container.getParent()); - - new GenericPersistenceUnitJarFilesComposite(this, container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitJarFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitJarFilesComposite.java deleted file mode 100644 index 7fde0e2c0f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitJarFilesComposite.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.swt.widgets.Composite; - -public class GenericPersistenceUnitJarFilesComposite - extends PersistenceUnitJarFilesComposite -{ - public GenericPersistenceUnitJarFilesComposite( - Pane<? extends PersistenceUnit> parentPane, - Composite parent) { - - super(parentPane, parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitMappingFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitMappingFilesComposite.java deleted file mode 100644 index c99cbb4d4b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceUnitMappingFilesComposite.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitGeneralComposite - The parent container - * @see AddRemoveListPane - * - * @version 2.0 - * @since 2.0 - */ -public class GenericPersistenceUnitMappingFilesComposite extends PersistenceUnitMappingFilesComposite -{ - /** - * Creates a new <code>PersistenceUnitMappingFilesComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public GenericPersistenceUnitMappingFilesComposite(Pane<? extends PersistenceUnit> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - @Override - protected void initializeLayout(Composite container) { - addMappingFilesList(container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceXmlUiFactory.java deleted file mode 100644 index 5a98afe62e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/GenericPersistenceXmlUiFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.persistence.details; - -import java.util.ArrayList; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.swt.widgets.Composite; - -public class GenericPersistenceXmlUiFactory implements PersistenceXmlUiFactory -{ - // **************** persistence unit composites **************************** - - public ListIterator<JpaPageComposite> createPersistenceUnitComposites( - PropertyValueModel<PersistenceUnit> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - ArrayList<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(3); - - pages.add(new GenericPersistenceUnitGeneralComposite(subjectHolder, parent, widgetFactory)); - pages.add(new PersistenceUnitConnectionComposite(subjectHolder, parent, widgetFactory)); - pages.add(new PersistenceUnitPropertiesComposite(subjectHolder, parent, widgetFactory)); - - return pages.listIterator(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitClassesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitClassesComposite.java deleted file mode 100644 index fe474335d2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitClassesComposite.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import java.util.ListIterator; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.ui.progress.IProgressService; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | Description | - * | | - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | x Exclude Unlisted Mapped Classes | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitGeneralComposite - The parent container - * @see AddRemoveListPane - * - * @version 2.3 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class PersistenceUnitClassesComposite extends Pane<PersistenceUnit> -{ - /** - * Creates a new <code>PersistenceUnitMappedClassesComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistenceUnitClassesComposite(Pane<? extends PersistenceUnit> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - private void addMappedClass(ObjectListSelectionModel listSelectionModel) { - - IType type = chooseType(); - - if (type != null) { - String className = type.getFullyQualifiedName('$'); - if(classRefExists(className)) { - return; - } - ClassRef classRef = getSubject().addSpecifiedClassRef(className); - listSelectionModel.setSelectedValue(classRef); - } - } - - private boolean classRefExists(String className) { - for ( ListIterator<ClassRef> i = getSubject().specifiedClassRefs(); i.hasNext(); ) { - ClassRef classRef = i.next(); - if( classRef.getClassName().equals(className)) { - return true; - } - } - return false; - } - - private Adapter buildAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addMappedClass(listSelectionModel); - } - - @Override - public boolean enableOptionOnSelectionChange(ObjectListSelectionModel listSelectionModel) { - if (!super.enableOptionOnSelectionChange(listSelectionModel)) { - return false; - } - - return findType((ClassRef) listSelectionModel.selectedValue()) != null; - } - - @Override - public boolean hasOptionalButton() { - return true; - } - - @Override - public String optionalButtonText() { - return JptUiPersistenceMessages.PersistenceUnitClassesComposite_open; - } - - @Override - public void optionOnSelection(ObjectListSelectionModel listSelectionModel) { - openMappedClass((ClassRef) listSelectionModel.selectedValue()); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeSpecifiedClassRef((ClassRef) item); - } - } - }; - } - - private WritablePropertyValueModel<Boolean> buildExcludeUnlistedMappedClassesHolder() { - return new PropertyAspectAdapter<PersistenceUnit, Boolean>( - getSubjectHolder(), - PersistenceUnit.SPECIFIED_EXCLUDE_UNLISTED_CLASSES_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedExcludeUnlistedClasses(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedExcludeUnlistedClasses(value); - } - }; - } - - private PropertyValueModel<String> buildExcludeUnlistedMappedClassesStringHolder() { - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultExcludeUnlistedMappedClassesHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptCommonUiMessages.Boolean_True : JptCommonUiMessages.Boolean_False; - return NLS.bind(JptUiPersistenceMessages.PersistenceUnitClassesComposite_excludeUnlistedMappedClassesWithDefault, defaultStringValue); - } - return JptUiPersistenceMessages.PersistenceUnitClassesComposite_excludeUnlistedMappedClasses; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultExcludeUnlistedMappedClassesHolder() { - return new PropertyAspectAdapter<PersistenceUnit, Boolean>( - getSubjectHolder(), - PersistenceUnit.SPECIFIED_EXCLUDE_UNLISTED_CLASSES_PROPERTY, - PersistenceUnit.DEFAULT_EXCLUDE_UNLISTED_CLASSES_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedExcludeUnlistedClasses() != null) { - return null; - } - return Boolean.valueOf(this.subject.getDefaultExcludeUnlistedClasses()); - } - }; - } - private ILabelProvider buildLabelProvider() { - return new LabelProvider() { - @Override - public Image getImage(Object element) { - ClassRef classRef = (ClassRef) element; - JavaPersistentType persistentType = classRef.getJavaPersistentType(); - Image image = null; - - if (persistentType != null) { - image = JpaMappingImageHelper.imageForTypeMapping(persistentType.getMappingKey()); - } - - if (image != null) { - return image; - } - - return JptJpaUiPlugin.getImage(JptUiIcons.WARNING); - } - - @Override - public String getText(Object element) { - ClassRef classRef = (ClassRef) element; - String name = classRef.getClassName(); - - if (name == null) { - name = JptUiPersistenceMessages.PersistenceUnitClassesComposite_mappedClassesNoName; - } - - return name; - } - }; - } - - private ListValueModel<ClassRef> buildItemListHolder() { - return new ItemPropertyListValueModelAdapter<ClassRef>( - buildListHolder(), - ClassRef.JAVA_PERSISTENT_TYPE_PROPERTY, - ClassRef.CLASS_NAME_PROPERTY - ); - } - - private ListValueModel<ClassRef> buildListHolder() { - return new ListAspectAdapter<PersistenceUnit, ClassRef>(getSubjectHolder(), PersistenceUnit.SPECIFIED_CLASS_REFS_LIST) { - @Override - protected ListIterator<ClassRef> listIterator_() { - return subject.specifiedClassRefs(); - } - - @Override - protected int size_() { - return subject.specifiedClassRefsSize(); - } - }; - } - - private WritablePropertyValueModel<ClassRef> buildSelectedItemHolder() { - return new SimplePropertyValueModel<ClassRef>(); - } - - /** - * Prompts the user the Open Type dialog. - * - * @return Either the selected type or <code>null</code> if the user - * canceled the dialog - */ - private IType chooseType() { - IJavaProject javaProject = getJavaProject(); - IJavaElement[] elements = new IJavaElement[] { javaProject }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements); - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - SelectionDialog typeSelectionDialog; - - try { - typeSelectionDialog = JavaUI.createTypeDialog( - getShell(), - service, - scope, - IJavaElementSearchConstants.CONSIDER_CLASSES, - false, - "" - ); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - return null; - } - - typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle); - typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage); - - if (typeSelectionDialog.open() == Window.OK) { - return (IType) typeSelectionDialog.getResult()[0]; - } - - return null; - } - - private IType findType(ClassRef classRef) { - String className = classRef.getClassName(); - - if (className != null) { - try { - return getSubject().getJpaProject().getJavaProject().findType(className.replace('$', '.')); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - } - - return null; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Description - addMultiLineLabel( - container, - JptUiPersistenceMessages.PersistenceUnitClassesComposite_description - ); - - // List pane - new AddRemoveListPane<PersistenceUnit>( - this, - container, - this.buildAdapter(), - this.buildItemListHolder(), - this.buildSelectedItemHolder(), - this.buildLabelProvider(), - JpaHelpContextIds.PERSISTENCE_XML_GENERAL - ) - { - @Override - protected void initializeTable(Table table) { - super.initializeTable(table); - - Composite container = table.getParent(); - GridData gridData = (GridData) container.getLayoutData(); - gridData.heightHint = 75; - } - }; - - this.addTriStateCheckBoxWithDefault( - container, - JptUiPersistenceMessages.PersistenceUnitClassesComposite_excludeUnlistedMappedClasses, - buildExcludeUnlistedMappedClassesHolder(), - buildExcludeUnlistedMappedClassesStringHolder(), - JpaHelpContextIds.PERSISTENCE_XML_GENERAL - ); - } - - private void openMappedClass(ClassRef classRef) { - - IType type = findType(classRef); - - if (type != null) { - try { - IJavaElement javaElement = type.getParent(); - JavaUI.openInEditor(javaElement, true, true); - } - catch (PartInitException e) { - JptJpaUiPlugin.log(e); - } - catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - } - } - - private IJavaProject getJavaProject() { - return getSubject().getJpaProject().getJavaProject(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionComposite.java deleted file mode 100644 index 6214cb00ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionComposite.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - General --------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitConnectionGeneralComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | - Database -------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitConnectionDatabaseComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitConnectionGeneralComposite - * @see PersistenceUnitConnectionDatabaseComposite - * - * @version 2.0 - * @since 2.0 - */ -public class PersistenceUnitConnectionComposite extends Pane<PersistenceUnit> - implements JpaPageComposite -{ - /** - * Creates a new <code>PersistenceUnitConnectionComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public PersistenceUnitConnectionComposite(PropertyValueModel<PersistenceUnit> subjectHolder, - Composite container, - WidgetFactory widgetFactory) { - - super(subjectHolder, container, widgetFactory); - } - - /* - * (non-Javadoc) - */ - @Override - protected Composite addContainer(Composite parent) { - - GridLayout layout = new GridLayout(1, true); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.marginTop = 0; - layout.marginLeft = 0; - layout.marginBottom = 0; - layout.marginRight = 0; - layout.verticalSpacing = 15; - - Composite container = addPane(parent, layout); - updateGridData(container); - - return container; - } - - /* - * (non-Javadoc) - */ - public String getHelpID() { - return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; - } - - private void initializeDatabasePane(Composite container) { - - container = addSection( - container, - JptUiPersistenceMessages.PersistenceUnitConnectionComposite_database - ); - - new PersistenceUnitConnectionDatabaseComposite(this, container); - } - - private void initializeGeneralPane(Composite container) { - - container = addSection( - container, - JptUiPersistenceMessages.PersistenceUnitConnectionComposite_general - ); - - new PersistenceUnitConnectionGeneralComposite(this, container); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - initializeGeneralPane(container); - initializeDatabasePane(container); - } - - public ImageDescriptor getPageImageDescriptor() { - return null; - } - - public String getPageText() { - return JptUiPersistenceMessages.PersistenceUnitConnectionComposite_connection; - } - - private void updateGridData(Composite container) { - - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionDatabaseComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionDatabaseComposite.java deleted file mode 100644 index a4f72a4b0d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionDatabaseComposite.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------ | - * | JTA Datasource Name: | I | | - * | ------------------------------------------------ | - * | ------------------------------------------------ | - * | Non-JTA Datasource Name: | I | | - * | ------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitConnectionComposite - The parent container - * - * @version 2.0 - * @since 2.0 - */ -public class PersistenceUnitConnectionDatabaseComposite extends Pane<PersistenceUnit> -{ - /** - * Creates a new <code>PersistenceUnitConnectionDatabaseComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistenceUnitConnectionDatabaseComposite(Pane<PersistenceUnit> subjectHolder, - Composite container) { - - super(subjectHolder, container); - } - - private PropertyValueModel<Boolean> buildJTADatasourceNameBooleanHolder() { - return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) { - @Override - protected Boolean transform_(PersistenceUnitTransactionType value) { - return Boolean.valueOf(value == PersistenceUnitTransactionType.JTA); - } - }; - } - - private WritablePropertyValueModel<String> buildJTADatasourceNameHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.JTA_DATA_SOURCE_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getJtaDataSource(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - subject.setJtaDataSource(value); - } - }; - } - - private PropertyValueModel<Boolean> buildNonJTADatasourceNameBooleanHolder() { - return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) { - @Override - protected Boolean transform_(PersistenceUnitTransactionType value) { - return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL); - } - }; - } - - private WritablePropertyValueModel<String> buildNonJTADatasourceNameHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.NON_JTA_DATA_SOURCE_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getNonJtaDataSource(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - subject.setNonJtaDataSource(value); - } - }; - } - - private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() { - return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>( - getSubjectHolder(), - PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY, - PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY) - { - @Override - protected PersistenceUnitTransactionType buildValue_() { - return subject.getTransactionType(); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // JTA Datasource Name widgets - PropertyValueModel<Boolean> enabled = this.buildJTADatasourceNameBooleanHolder(); - Label label = addLabel( - container, - JptUiPersistenceMessages.PersistenceUnitConnectionDatabaseComposite_jtaDatasourceName, - enabled - ); - Text text = addText( - container, - buildJTADatasourceNameHolder(), - JpaHelpContextIds.PERSISTENCE_XML_CONNECTION, - enabled - ); - addLabeledComposite(container, label, text, JpaHelpContextIds.PERSISTENCE_XML_CONNECTION); - - - // Non-JTA Datasource Name widgets - enabled = this.buildNonJTADatasourceNameBooleanHolder(); - label = addLabel( - container, - JptUiPersistenceMessages.PersistenceUnitConnectionDatabaseComposite_nonJtaDatasourceName, - enabled - ); - text = addText( - container, - buildNonJTADatasourceNameHolder(), - JpaHelpContextIds.PERSISTENCE_XML_CONNECTION, - enabled - ); - addLabeledComposite(container, label, text, JpaHelpContextIds.PERSISTENCE_XML_CONNECTION); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionGeneralComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionGeneralComposite.java deleted file mode 100644 index be160c8996..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitConnectionGeneralComposite.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.persistence.details; - -import java.util.Collection; -import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------ | - * | Transaction Type: | |v| | - * | ------------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitConnectionComposite - The parent container - * - * @version 2.0 - * @since 2.0 - */ -public class PersistenceUnitConnectionGeneralComposite extends Pane<PersistenceUnit> -{ - /** - * Creates a new <code>PersistenceUnitConnectionGeneralComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistenceUnitConnectionGeneralComposite(Pane<PersistenceUnit> subjectHolder, - Composite container) { - - super(subjectHolder, container); - } - - private EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) { - - return new EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY); - propertyNames.add(PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY); - } - - @Override - protected PersistenceUnitTransactionType[] getChoices() { - return PersistenceUnitTransactionType.values(); - } - - @Override - protected PersistenceUnitTransactionType getDefaultValue() { - return getSubject().getDefaultTransactionType(); - } - - @Override - protected String displayString(PersistenceUnitTransactionType value) { - return buildDisplayString( - JptUiPersistenceMessages.class, - PersistenceUnitConnectionGeneralComposite.this, - value - ); - } - - @Override - protected PersistenceUnitTransactionType getValue() { - return getSubject().getSpecifiedTransactionType(); - } - - @Override - protected void setValue(PersistenceUnitTransactionType value) { - getSubject().setSpecifiedTransactionType(value); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Transaction Type widgets - addLabeledComposite( - container, - JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_transactionType, - buildTransactionTypeCombo(container).getControl(), - JpaHelpContextIds.PERSISTENCE_XML_CONNECTION - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitGeneralComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitGeneralComposite.java deleted file mode 100644 index 00d02e800c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitGeneralComposite.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - General --------------------------------------------------------------- | - * | ------------------------------------------------- | - * | Name: | I | | - * | ------------------------------------------------- | - * | ------------------------------------------------- | - * | Persistence Provider: | |v| | - * | ------------------------------------------------- | - * | | - * | | - * | - Mapped Classes -------------------------------------------------------- | - * | | - * | Description | - * | | - * | ----------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitMappedClassesComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * | | - * | | - * | - XML Mapping Files ----------------------------------------------------- | - * | | - * | Description | - * | | - * | ----------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitMappingFilesComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * | | - * | | - * | - JAR Files ------------------------------------------------------------- | - * | | - * | Description | - * | | - * | ----------------------------------------------------------------------- | - * | | | | - * | | PersistenceUnitJarFilesComposite | | - * | | | | - * | ----------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitMappedClassesComposite - * @see PersistenceUnitMappingFilesComposite - * @see PersistenceUnitJarFilesComposite - * - * @version 2.0 - * @since 2.0 - */ -public abstract class PersistenceUnitGeneralComposite extends Pane<PersistenceUnit> - implements JpaPageComposite -{ - /** - * Creates a new <code>PersistenceUnitGeneralComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public PersistenceUnitGeneralComposite(PropertyValueModel<? extends PersistenceUnit> subjectHolder, - Composite container, - WidgetFactory widgetFactory) { - - super(subjectHolder, container, widgetFactory); - } - - - /* - * (non-Javadoc) - */ - @Override - protected Composite addContainer(Composite parent) { - Composite container = addSubPane(parent); - updateGridData(container); - - return container; - } - - private WritablePropertyValueModel<String> buildPersistenceProviderHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.PROVIDER_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getProvider(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - subject.setProvider(value); - } - }; - } - - private WritablePropertyValueModel<String> buildPersistenceUnitNameHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getName(); - } - - @Override - protected void setValue_(String value) { - subject.setName(value); - } - }; - } - - private WritablePropertyValueModel<String> buildPersistenceUnitDescriptionHolder() { - return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.DESCRIPTION_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getDescription(); - } - - @Override - protected void setValue_(String value) { - if (value.length() == 0) { - value = null; - } - subject.setDescription(value); - } - }; - } - - /* - * (non-Javadoc) - */ - public String getHelpID() { - return JpaHelpContextIds.PERSISTENCE_XML_GENERAL; - } - - public ImageDescriptor getPageImageDescriptor() { - return null; - } - - /* - * (non-Javadoc) - */ - public String getPageText() { - return JptUiPersistenceMessages.PersistenceUnitGeneralComposite_general; - } - - protected void initializeGeneralPane(Composite container) { - - container = this.addSection( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_general - ); - - // Name widgets - this.addLabeledText( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_name, - this.buildPersistenceUnitNameHolder(), - this.getHelpID() - ); - - // Persistence Provider widgets - this.addLabeledText( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_persistenceProvider, - this.buildPersistenceProviderHolder(), - this.getHelpID() - ); - - // Description widgets - this.addLabeledText( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_description, - this.buildPersistenceUnitDescriptionHolder(), - this.getHelpID() - ); - } - - protected void initializeMappedClassesPane(Composite container) { - - container = addCollapsibleSection( - container, - JptUiPersistenceMessages.PersistenceUnitGeneralComposite_mappedClasses - ); - - updateGridData(container); - updateGridData(container.getParent()); - - new PersistenceUnitClassesComposite(this, container); - } - - protected void updateGridData(Composite container) { - - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitJarFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitJarFilesComposite.java deleted file mode 100644 index 8a2fc7cd7b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitJarFilesComposite.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import java.util.ListIterator; -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | Description | - * | | - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see PersistenceUnitGeneralComposite - The parent container - * @see AddRemoveListPane - * - * @version 2.0 - * @since 2.0 - */ -public abstract class PersistenceUnitJarFilesComposite - extends Pane<PersistenceUnit> -{ - /** - * Creates a new <code>PersistenceUnitJPAMappingDescriptorsComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistenceUnitJarFilesComposite( - Pane<? extends PersistenceUnit> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - - - @Override - protected void initializeLayout(Composite container) { - addJarFilesList(container); - } - - protected void addJarFilesList(Composite container) { - // List pane - new AddRemoveListPane<PersistenceUnit>( - this, - container, - this.buildAdapter(), - this.buildItemListHolder(), - this.buildSelectedItemHolder(), - this.buildLabelProvider(), - JpaHelpContextIds.PERSISTENCE_XML_GENERAL - ) { - @Override - protected Composite addContainer(Composite parent) { - parent = super.addContainer(parent); - updateGridData(parent); - return parent; - } - - @Override - protected void initializeLayout(Composite container) { - super.initializeLayout(container); - updateGridData(getContainer()); - } - }; - } - - private void updateGridData(Composite container) { - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } - - private Adapter buildAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addJarFileRef(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeJarFileRef((JarFileRef) item); - } - } - }; - } - - private ListValueModel<JarFileRef> buildItemListHolder() { - return new ItemPropertyListValueModelAdapter<JarFileRef>( - buildListHolder(), - JarFileRef.FILE_NAME_PROPERTY - ); - } - - private ListValueModel<JarFileRef> buildListHolder() { - return new ListAspectAdapter<PersistenceUnit, JarFileRef>(getSubjectHolder(), PersistenceUnit.JAR_FILE_REFS_LIST) { - @Override - protected ListIterator<JarFileRef> listIterator_() { - return this.subject.jarFileRefs(); - } - - @Override - protected int size_() { - return this.subject.jarFileRefsSize(); - } - }; - } - - private WritablePropertyValueModel<JarFileRef> buildSelectedItemHolder() { - return new SimplePropertyValueModel<JarFileRef>(); - } - - private ILabelProvider buildLabelProvider() { - return new LabelProvider() { - @Override - public Image getImage(Object element) { - return JptJpaUiPlugin.getImage(JptUiIcons.JAR_FILE_REF); - } - - @Override - public String getText(Object element) { - JarFileRef jarFileRef = (JarFileRef) element; - String name = jarFileRef.getFileName(); - - if (name == null) { - name = JptUiPersistenceMessages.PersistenceUnitJarFilesComposite_noFileName; - } - - return name; - } - }; - } - - private void addJarFileRef(ObjectListSelectionModel listSelectionModel) { - IProject project = getSubject().getJpaProject().getProject(); - - ElementTreeSelectionDialog dialog = new ArchiveFileSelectionDialog( - getShell(), buildJarFileDeploymentPathCalculator()); - - dialog.setHelpAvailable(false); - dialog.setTitle(JptUiPersistenceMessages.PersistenceUnitMappingFilesComposite_jarFileDialog_title); - dialog.setMessage(JptUiPersistenceMessages.PersistenceUnitMappingFilesComposite_jarFileDialog_message); - dialog.setInput(project); - - SWTUtil.show( - dialog, - buildSelectionDialogPostExecution(listSelectionModel) - ); - } - - protected ArchiveFileSelectionDialog.DeploymentPathCalculator buildJarFileDeploymentPathCalculator() { - return new ArchiveFileSelectionDialog.ModuleDeploymentPathCalculator(); - } - - private PostExecution<ElementTreeSelectionDialog> buildSelectionDialogPostExecution( - final ObjectListSelectionModel listSelectionModel) { - return new PostExecution<ElementTreeSelectionDialog>() { - public void execute(ElementTreeSelectionDialog dialog) { - if (dialog.getReturnCode() == IDialogConstants.CANCEL_ID) { - return; - } - - for (Object result : dialog.getResult()) { - String filePath = (String) result; - if (jarFileRefExists(filePath)) { - continue; - } - JarFileRef jarFileRef = getSubject().addJarFileRef(filePath); - - listSelectionModel.addSelectedValue(jarFileRef); - } - } - }; - } - - private boolean jarFileRefExists(String fileName) { - for (JarFileRef each : CollectionTools.iterable(getSubject().jarFileRefs())) { - if (each.getFileName().equals(fileName)) { - return true; - } - } - return false; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitMappingFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitMappingFilesComposite.java deleted file mode 100644 index a0afca0774..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitMappingFilesComposite.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import java.util.ListIterator; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.navigator.ResourceComparator; - -@SuppressWarnings("nls") -public abstract class PersistenceUnitMappingFilesComposite - extends Pane<PersistenceUnit> { - - public PersistenceUnitMappingFilesComposite( - Pane<? extends PersistenceUnit> parentPane, Composite parent) { - - super(parentPane, parent); - } - - - protected void addMappingFilesList(Composite container) { - // List pane - new AddRemoveListPane<PersistenceUnit>( - this, - container, - buildAdapter(), - buildItemListHolder(), - buildSelectedItemHolder(), - buildLabelProvider(), - JpaHelpContextIds.PERSISTENCE_XML_GENERAL) { - - @Override - protected Composite addContainer(Composite parent) { - parent = super.addContainer(parent); - updateGridData(parent); - return parent; - } - - @Override - protected void initializeLayout(Composite container) { - super.initializeLayout(container); - updateGridData(getContainer()); - } - }; - } - - /** - * Prompts a dialog showing a tree structure of the source paths where the - * only files shown are JPA mapping descriptors file. The XML file has to be - * an XML file with the root tag: {@code <entity-mappings>}. - * - * @param listSelectionModel The selection model used to select the new files - */ - private void addJPAMappingDescriptor(ObjectListSelectionModel listSelectionModel) { - - IProject project = getSubject().getJpaProject().getProject(); - - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( - getShell(), - new WorkbenchLabelProvider(), - new WorkbenchContentProvider()); - - dialog.setHelpAvailable(false); - dialog.setValidator(buildValidator()); - dialog.setTitle(JptUiPersistenceMessages.PersistenceUnitMappingFilesComposite_mappingFileDialog_title); - dialog.setMessage(JptUiPersistenceMessages.PersistenceUnitMappingFilesComposite_mappingFileDialog_message); - dialog.addFilter(new XmlMappingFileViewerFilter(getSubject().getJpaProject())); - dialog.setInput(project); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - - SWTUtil.show( - dialog, - buildSelectionDialogPostExecution(listSelectionModel)); - } - - private Adapter buildAdapter() { - return new AddRemoveListPane.AbstractAdapter() { - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - addJPAMappingDescriptor(listSelectionModel); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeSpecifiedMappingFileRef((MappingFileRef) item); - } - } - }; - } - - @Override - protected Composite addContainer(Composite parent) { - - GridLayout layout = new GridLayout(1, true); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.marginTop = 0; - layout.marginLeft = 0; - layout.marginBottom = 0; - layout.marginRight = 0; - - Composite container = addPane(parent, layout); - updateGridData(container); - - return container; - } - - private ListValueModel<MappingFileRef> buildItemListHolder() { - return new ItemPropertyListValueModelAdapter<MappingFileRef>( - buildListHolder(), - MappingFileRef.FILE_NAME_PROPERTY); - } - - private ILabelProvider buildLabelProvider() { - return new LabelProvider() { - @Override - public Image getImage(Object element) { - return JptJpaUiPlugin.getImage(JptUiIcons.MAPPING_FILE_REF); - } - - @Override - public String getText(Object element) { - MappingFileRef mappingFileRef = (MappingFileRef) element; - String name = mappingFileRef.getFileName(); - - if (name == null) { - name = JptUiPersistenceMessages.PersistenceUnitMappingFilesComposite_ormNoName; - } - - return name; - } - }; - } - - private ListValueModel<MappingFileRef> buildListHolder() { - return new ListAspectAdapter<PersistenceUnit, MappingFileRef>( - getSubjectHolder(), PersistenceUnit.SPECIFIED_MAPPING_FILE_REFS_LIST) { - - @Override - protected ListIterator<MappingFileRef> listIterator_() { - return this.subject.specifiedMappingFileRefs(); - } - - @Override - protected int size_() { - return this.subject.specifiedMappingFileRefsSize(); - } - }; - } - - private WritablePropertyValueModel<MappingFileRef> buildSelectedItemHolder() { - return new SimplePropertyValueModel<MappingFileRef>(); - } - - private PostExecution<ElementTreeSelectionDialog> buildSelectionDialogPostExecution( - final ObjectListSelectionModel listSelectionModel) { - - return new PostExecution<ElementTreeSelectionDialog>() { - - public void execute(ElementTreeSelectionDialog dialog) { - - if (dialog.getReturnCode() == IDialogConstants.CANCEL_ID) { - return; - } - - for (Object result : dialog.getResult()) { - IFile file = (IFile) result; - IProject project = file.getProject(); - IPath runtimePath = JptCommonCorePlugin.getResourceLocator(project).getRuntimePath(project, file.getFullPath()); - String fileName = runtimePath.toPortableString(); - if (mappingFileRefExists(fileName)) { - continue; - } - MappingFileRef mappingFileRef = getSubject().addSpecifiedMappingFileRef(fileName); - - listSelectionModel.addSelectedValue(mappingFileRef); - } - } - }; - } - - private boolean mappingFileRefExists(String fileName) { - for ( ListIterator<MappingFileRef> i = getSubject().specifiedMappingFileRefs(); i.hasNext(); ) { - MappingFileRef mappingFileRef = i.next(); - if( mappingFileRef.getFileName().equals(fileName)) { - return true; - } - } - return false; - } - - private ISelectionStatusValidator buildValidator() { - return new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - - if (selection.length == 0) { - return new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, ""); - } - - for (Object item : selection) { - if (item instanceof IFolder) { - return new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, ""); - } - } - - return new Status(IStatus.OK, JptJpaUiPlugin.PLUGIN_ID, ""); - } - }; - } - - private void updateGridData(Composite container) { - - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - gridData.verticalAlignment = SWT.FILL; - container.setLayoutData(gridData); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitPropertiesComposite.java deleted file mode 100644 index 9c8c70e698..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceUnitPropertiesComposite.java +++ /dev/null @@ -1,419 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.persistence.details; - -import java.util.ListIterator; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveTablePane; -import org.eclipse.jpt.common.ui.internal.widgets.Pane; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.common.utility.model.event.ListAddEvent; -import org.eclipse.jpt.common.utility.model.event.ListChangeEvent; -import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory; -import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Properties ------------------------------------------------------------ | - * | | - * | Description | - * | | - * | ----------------------------------------------------------------------- | - * | | | | - * | | AddRemoveTablePane | | - * | | | | - * | ----------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see PersistenceUnit - * @see BaseJavaUiFactory - The invoker - * @see AddRemoveTablePane - * - * @version 2.3 - * @since 2.0 - */ -@SuppressWarnings("nls") -public class PersistenceUnitPropertiesComposite extends Pane<PersistenceUnit> - implements JpaPageComposite -{ - private WritablePropertyValueModel<PersistenceUnit.Property> propertyHolder; - private TablePane tablePane; - - /** - * Creates a new <code>PersistenceUnitPropertiesComposite</code>. - * - * @param subjectHolder The holder of this pane's subject - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public PersistenceUnitPropertiesComposite(PropertyValueModel<PersistenceUnit> subjectHolder, - Composite container, - WidgetFactory widgetFactory) { - - super(subjectHolder, container, widgetFactory); - } - - private ListValueModel<PersistenceUnit.Property> buildPropertiesListHolder() { - return new ListAspectAdapter<PersistenceUnit, PersistenceUnit.Property>(getSubjectHolder(), PersistenceUnit.PROPERTIES_LIST) { - @Override - protected ListIterator<PersistenceUnit.Property> listIterator_() { - return subject.properties(); - } - - @Override - protected int size_() { - return subject.propertiesSize(); - } - }; - } - - private ITableLabelProvider buildPropertyLabelProvider() { - return new TableLabelProvider(); - } - - private AddRemoveTablePane.Adapter buildTableAdapter() { - return new AddRemoveTablePane.AbstractAdapter() { - - public void addNewItem(ObjectListSelectionModel listSelectionModel) { - - PersistenceUnit.Property property = getSubject().addProperty(); - propertyHolder.setValue(property); - - tablePane.getTableViewer().editElement( - property, - PropertyColumnAdapter.NAME_COLUMN - ); - } - - public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) { - for (Object item : listSelectionModel.selectedValues()) { - getSubject().removeProperty((PersistenceUnit.Property) item); - } - } - }; - } - - public String getHelpID() { - return JpaHelpContextIds.PERSISTENCE_XML_PROPERTIES; - } - - public ImageDescriptor getPageImageDescriptor() { - return null; - } - - public String getPageText() { - return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_properties; - } - - @Override - protected void initialize() { - super.initialize(); - propertyHolder = new SimplePropertyValueModel<PersistenceUnit.Property>(); - } - - @Override - protected void initializeLayout(Composite container) { - - addLabel( - container, - JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_properties_description - ); - - tablePane = new TablePane(container); - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - } - - private static class PropertyColumnAdapter implements ColumnAdapter<PersistenceUnit.Property> { - - public static final int COLUMN_COUNT = 3; - public static final int NAME_COLUMN = 1; - public static final int SELECTION_COLUMN = 0; - public static final int VALUE_COLUMN = 2; - - private WritablePropertyValueModel<String> buildNameHolder(PersistenceUnit.Property subject) { - return new PropertyAspectAdapter<PersistenceUnit.Property, String>(PersistenceUnit.Property.NAME_PROPERTY, subject) { - @Override - protected String buildValue_() { - return subject.getName(); - } - - @Override - protected void setValue_(String value) { - subject.setName(value); - } - }; - } - - private WritablePropertyValueModel<String> buildValueHolder(PersistenceUnit.Property subject) { - return new PropertyAspectAdapter<PersistenceUnit.Property, String>(PersistenceUnit.Property.VALUE_PROPERTY, subject) { - @Override - protected String buildValue_() { - return subject.getValue(); - } - - @Override - protected void setValue_(String value) { - subject.setValue(value); - } - }; - } - - public WritablePropertyValueModel<?>[] cellModels(PersistenceUnit.Property subject) { - WritablePropertyValueModel<?>[] holders = new WritablePropertyValueModel<?>[COLUMN_COUNT]; - holders[SELECTION_COLUMN] = new SimplePropertyValueModel<Object>(); - holders[NAME_COLUMN] = buildNameHolder(subject); - holders[VALUE_COLUMN] = buildValueHolder(subject); - return holders; - } - - public int columnCount() { - return COLUMN_COUNT; - } - - public String columnName(int columnIndex) { - - switch (columnIndex) { - case PropertyColumnAdapter.NAME_COLUMN: { - return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_nameColumn; - } - - case PropertyColumnAdapter.VALUE_COLUMN: { - return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_valueColumn; - } - - default: { - return null; - } - } - } - } - - private class TableLabelProvider extends LabelProvider - implements ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - - PersistenceUnit.Property property = (PersistenceUnit.Property) element; - String value = null; - - switch (columnIndex) { - case PropertyColumnAdapter.NAME_COLUMN: { - value = property.getName(); - break; - } - - case PropertyColumnAdapter.VALUE_COLUMN: { - value = property.getValue(); - break; - } - } - - if (value == null) { - value = ""; - } - - return value; - } - } - - private class TablePane extends AddRemoveTablePane<PersistenceUnit> { - - private final String SELECTION_COLUMN = "selection"; - - private TableViewer tableViewer; - - private TablePane(Composite parent) { - super(PersistenceUnitPropertiesComposite.this, - parent, - buildTableAdapter(), - buildPropertiesListHolder(), - propertyHolder, - buildPropertyLabelProvider()); - } - - @Override - protected Composite addContainer(Composite parent) { - Composite container = super.addContainer(parent); - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - return container; - } - - private CellEditor[] buildCellEditors(Table table) { - return new CellEditor[] { - null, - new TextCellEditor(table), - new TextCellEditor(table) - }; - } - - private ICellModifier buildCellModifier() { - return new ICellModifier() { - - public boolean canModify(Object element, String property) { - return !SELECTION_COLUMN.equals(property); - } - - public Object getValue(Object element, String property) { - PersistenceUnit.Property propertyModel = (PersistenceUnit.Property) element; - String value = null; - - if (property == PersistenceUnit.Property.NAME_PROPERTY) { - value = propertyModel.getName(); - } - else if (property == PersistenceUnit.Property.VALUE_PROPERTY) { - value = propertyModel.getValue(); - } - - if (value == null) { - value = ""; - } - - return value; - } - - public void modify(Object element, String property, Object value) { - PersistenceUnit.Property propertyModel; - - if (element instanceof TableItem) { - TableItem tableItem = (TableItem) element; - propertyModel = (PersistenceUnit.Property) tableItem.getData(); - } - else { - propertyModel = (PersistenceUnit.Property) element; - } - - if (property == PersistenceUnit.Property.NAME_PROPERTY) { - propertyModel.setName(value.toString()); - } - else if (property == PersistenceUnit.Property.VALUE_PROPERTY) { - propertyModel.setValue(value.toString()); - } - } - }; - } - - @Override - protected ColumnAdapter<?> buildColumnAdapter() { - return new PropertyColumnAdapter(); - } - - private String[] buildColumnProperties() { - return new String[] { - SELECTION_COLUMN, - PersistenceUnit.Property.NAME_PROPERTY, - PersistenceUnit.Property.VALUE_PROPERTY - }; - } - - TableViewer getTableViewer() { - return tableViewer; - } - - @Override - protected void initializeMainComposite(Composite container, - Adapter adapter, - ListValueModel<?> listHolder, - WritablePropertyValueModel<?> selectedItemHolder, - IBaseLabelProvider labelProvider, - String helpId) { - - super.initializeMainComposite( - container, - adapter, - listHolder, - selectedItemHolder, - labelProvider, - helpId - ); - - Table table = getMainControl(); - table.setLayoutData(new GridData(GridData.FILL_BOTH)); - - // Make the selection column non-resizable since it's only used to - // ease the selection of rows - TableColumn selectionColumn = table.getColumn(PropertyColumnAdapter.SELECTION_COLUMN); - selectionColumn.setResizable(false); - selectionColumn.setWidth(20); - - // Install the editors - tableViewer = new TableViewer(table); - tableViewer.setCellEditors(buildCellEditors(table)); - tableViewer.setCellModifier(buildCellModifier()); - tableViewer.setColumnProperties(buildColumnProperties()); - } - - @Override - protected void itemsAdded(ListAddEvent e) { - super.itemsAdded(e); - revalidateLayout(); - } - - @Override - protected void itemsRemoved(ListRemoveEvent e) { - super.itemsRemoved(e); - revalidateLayout(); - } - - @Override - protected void listChanged(ListChangeEvent e) { - super.listChanged(e); - revalidateLayout(); - } - - /** - * Revalidates the table layout after the list of items has changed. The - * layout has to be done in a new UI thread because our listener might be - * notified before the table has been updated (table column added or removed). - */ - private void revalidateLayout() { - SWTUtil.asyncExec(new Runnable() { public void run() { - Table table = getMainControl(); - if (!table.isDisposed()) { - // We have to do a total relayout of the tab otherwise the - // table might become cut off at the bottom - SWTUtil.reflow(table); - } - }}); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceXmlUiDefinition.java deleted file mode 100644 index ee2d04c5bb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceXmlUiDefinition.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.persistence.details; - -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceResourceModelStructureProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class PersistenceXmlUiDefinition extends AbstractPersistenceXmlResourceUiDefinition -{ - // singleton - private static final ResourceUiDefinition INSTANCE = new PersistenceXmlUiDefinition(); - - - /** - * Return the singleton - */ - public static ResourceUiDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private PersistenceXmlUiDefinition() { - super(); - } - - - @Override - protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() { - return new GenericPersistenceXmlUiFactory(); - } - - public boolean providesUi(JptResourceType resourceType) { - return resourceType.equals(JptJpaCorePlugin.PERSISTENCE_XML_1_0_RESOURCE_TYPE); - } - - public JpaStructureProvider getStructureProvider() { - return PersistenceResourceModelStructureProvider.instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceXmlUiFactory.java deleted file mode 100644 index 6f546cd681..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/details/PersistenceXmlUiFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.persistence.details; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.details.JpaPageComposite; -import org.eclipse.swt.widgets.Composite; - -public interface PersistenceXmlUiFactory -{ - // **************** persistence unit composites **************************** - - /** - * Creates the list of <code>JpaComposite</code>s used to edit a - * <code>PersistenceUnit</code>. The properties can be regrouped into - * sections that will be shown in the editor as pages. - * - * @param subjectHolder The holder of the pertistence unit - * @param parent The parent container - * @param widgetFactory The factory used to create the widgets - * @return A new <code>JpaComposite</code> - */ - ListIterator<JpaPageComposite> createPersistenceUnitComposites( - PropertyValueModel<PersistenceUnit> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/perspective/JpaPerspectiveFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/perspective/JpaPerspectiveFactory.java deleted file mode 100644 index 6402201b1f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/perspective/JpaPerspectiveFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.jpa.ui.internal.perspective; - -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; -import org.eclipse.ui.navigator.resources.ProjectExplorer; -import org.eclipse.ui.progress.IProgressConstants; - -public class JpaPerspectiveFactory implements IPerspectiveFactory { - - public void createInitialLayout(IPageLayout layout) { - String editorArea = layout.getEditorArea(); - - //Package area - IFolderLayout folder = layout.createFolder( - "left", IPageLayout.LEFT, (float) 0.25, editorArea); //$NON-NLS-1$ - folder.addView(ProjectExplorer.VIEW_ID); - folder.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY); - folder.addPlaceholder(IPageLayout.ID_RES_NAV); - - //Database Explorer area - layout.addView("org.eclipse.datatools.connectivity.DataSourceExplorerNavigator", //$NON-NLS-1$ - IPageLayout.BOTTOM, (float) 0.60, ProjectExplorer.VIEW_ID); - - //Problems/Console area - IFolderLayout outputFolder = layout.createFolder( - "bottom", IPageLayout.BOTTOM, (float) 0.60, editorArea); //$NON-NLS-1$ - outputFolder.addView(IPageLayout.ID_PROBLEM_VIEW); - outputFolder.addPlaceholder(IPageLayout.ID_BOOKMARKS); - outputFolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID); - - //JPA Details (Split with Problems/Console area) - layout.addView("org.eclipse.jpt.ui.jpaDetailsView", //$NON-NLS-1$ - IPageLayout.RIGHT, (float) .60, "bottom"); //$NON-NLS-1$ - - //JPA Structure area - IFolderLayout outlineFolder = layout.createFolder( - "right", IPageLayout.RIGHT, (float) 0.75, editorArea); //$NON-NLS-1$ - outlineFolder.addView("org.eclipse.jpt.ui.jpaStructureView"); //$NON-NLS-1$ - outlineFolder.addView(IPageLayout.ID_OUTLINE); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/JpaPlatformUiRegistry.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/JpaPlatformUiRegistry.java deleted file mode 100644 index 5d617afb1f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/JpaPlatformUiRegistry.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.platform; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiFactory; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; - -public class JpaPlatformUiRegistry -{ - // singleton - private static final JpaPlatformUiRegistry INSTANCE = new JpaPlatformUiRegistry(); - - /** - * Return the singleton. - */ - public static JpaPlatformUiRegistry instance() { - return INSTANCE; - } - - private static final String EXTENSION_ID = - "jpaPlatformUis"; //$NON-NLS-1$ - - private static final String EL_PLATFORM_UI = - "jpaPlatformUi"; //$NON-NLS-1$ - - private static final String AT_ID = - "id"; //$NON-NLS-1$ - - private static final String AT_JPA_PLATFORM = - "jpaPlatform"; //$NON-NLS-1$ - - private static final String AT_FACTORY_CLASS = - "factoryClass"; //$NON-NLS-1$ - - // key: String id value: IConfigurationElement class descriptor - private Map<String, IConfigurationElement> jpaPlatformUiConfigElements; - - //cache the jpaPlatformUis when they are built - //key: jpa platform id value: JpaPlaformUi - private Map<String, JpaPlatformUi> jpaPlatformUis; - - /* (non Java doc) - * restrict access - */ - private JpaPlatformUiRegistry() { - buildJpaPlatformUiConfigElements(); - this.jpaPlatformUis = new HashMap<String, JpaPlatformUi>(); - } - - - private void buildJpaPlatformUiConfigElements() { - this.jpaPlatformUiConfigElements = new HashMap<String, IConfigurationElement>(); - - for (Iterator<IConfigurationElement> stream = allConfigElements(); stream.hasNext(); ) { - buildJpaPlatformUi(stream.next()); - } - } - - private void buildJpaPlatformUi(IConfigurationElement configElement) { - if (! configElement.getName().equals(EL_PLATFORM_UI)) { - return; - } - - String platformUiId = configElement.getAttribute(AT_ID); - String platform = configElement.getAttribute(AT_JPA_PLATFORM); - String platformUiFactoryClass = configElement.getAttribute(AT_FACTORY_CLASS); - - if ((platformUiId == null) || (platformUiFactoryClass == null)) { - if (platformUiId == null) { - reportMissingAttribute(configElement, AT_ID); - } - if (platform == null) { - reportMissingAttribute(configElement, AT_JPA_PLATFORM); - } - if (platformUiFactoryClass == null) { - reportMissingAttribute(configElement, AT_FACTORY_CLASS); - } - return; - } - - if (this.jpaPlatformUiConfigElements.containsKey(platformUiId)) { - IConfigurationElement otherConfigElement = this.jpaPlatformUiConfigElements.get(platform); - reportDuplicatePlatformUi(configElement, otherConfigElement); - } - - this.jpaPlatformUiConfigElements.put(platformUiId, configElement); - } - - public JpaPlatformUi getJpaPlatformUi(String platformId) { - if (this.jpaPlatformUis.containsKey(platformId)) { - return this.jpaPlatformUis.get(platformId); - } - IConfigurationElement registeredConfigElement = null; - for (IConfigurationElement configurationElement : this.jpaPlatformUiConfigElements.values()) { - if (configurationElement.getAttribute(AT_JPA_PLATFORM).equals(platformId)) { - registeredConfigElement = configurationElement; - break; - } - } - - if (registeredConfigElement == null) { - return null; - } - JpaPlatformUiFactory jpaPlatformUiFactory; - try { - jpaPlatformUiFactory = (JpaPlatformUiFactory) registeredConfigElement.createExecutableExtension(AT_FACTORY_CLASS); - } - catch (CoreException ce) { - reportFailedInstantiation(registeredConfigElement); - throw new IllegalArgumentException(platformId); - } - JpaPlatformUi platformUi = jpaPlatformUiFactory.buildJpaPlatformUi(); - this.jpaPlatformUis.put(platformId, platformUi); - return platformUi; - } - - private Iterator<IConfigurationElement> allConfigElements() { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = - registry.getExtensionPoint(JptJpaUiPlugin.PLUGIN_ID, EXTENSION_ID); - IExtension[] extensions = extensionPoint.getExtensions(); - - return new CompositeIterator<IConfigurationElement>( - new TransformationIterator<IExtension, Iterator<IConfigurationElement>>(CollectionTools.iterator(extensions)) { - @Override - protected Iterator<IConfigurationElement> transform(IExtension extension) { - return CollectionTools.iterator(extension.getConfigurationElements()); - } - } - ); - } - - // TODO externalize strings - private void reportMissingAttribute(IConfigurationElement configElement, String attributeName) { - String message = - "An extension element \"" - + configElement.getName() - + "\" in plugin \"" - + configElement.getContributor().getName() - + "\" is missing a required attribute \"" - + attributeName - + "\"."; - JptJpaUiPlugin.log(message); - } - - // TODO externalize strings - private void reportDuplicatePlatformUi( - IConfigurationElement oneConfigElement, IConfigurationElement otherConfigElement) { - String message = - "The plugins \"" - + oneConfigElement.getContributor().getName() - + "\" and \"" - + otherConfigElement.getContributor().getName() - + "\" have registered a duplicate attribute \"id\" " - + "for the extension element \"jpaPlatformUi\"."; - JptJpaUiPlugin.log(message); - } - - // TODO externalize strings - private void reportFailedInstantiation(IConfigurationElement configElement) { - String message = - "Could not instantiate the class \"" - + configElement.getAttribute(AT_FACTORY_CLASS) - + "\" for the extension element \"" - + configElement.getName() - + "\" in the plugin \"" - + configElement.getContributor().getName() - + "\"."; - JptJpaUiPlugin.log(message); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/BaseJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/BaseJpaPlatformUi.java deleted file mode 100644 index a01135e3a4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/BaseJpaPlatformUi.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.platform.base; - -import java.util.Iterator; -import java.util.ListIterator; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.ResourceUiDefinition; -import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -public abstract class BaseJpaPlatformUi - implements JpaPlatformUi -{ - private final JpaNavigatorProvider navigatorProvider; - - private final JpaPlatformUiProvider platformUiProvider; - - - protected BaseJpaPlatformUi( - JpaNavigatorProvider navigatorProvider, JpaPlatformUiProvider platformUiProvider) { - - super(); - this.navigatorProvider = navigatorProvider; - this.platformUiProvider = platformUiProvider; - } - - - // ********** navigator provider ********** - - public JpaNavigatorProvider getNavigatorProvider() { - return this.navigatorProvider; - } - - - // ********** structure providers ********** - - public JpaStructureProvider getStructureProvider(JpaFile jpaFile) { - JptResourceType resourceType = jpaFile.getResourceModel().getResourceType(); - return (resourceType == null) ? null : this.getStructureProvider(resourceType); - } - - protected JpaStructureProvider getStructureProvider(JptResourceType resourceType) { - ResourceUiDefinition definition; - try { - definition = getResourceUiDefinition(resourceType); - } - catch (IllegalArgumentException iae) { - JptJpaUiPlugin.log(iae); - return null; - } - return definition.getStructureProvider(); - } - - - // ********** details providers ********** - - public JpaDetailsPage<? extends JpaStructureNode> buildJpaDetailsPage( - Composite parent, JpaStructureNode structureNode, WidgetFactory widgetFactory) { - - JpaDetailsProvider jpaDetailsProvider = getDetailsProvider(structureNode); - return jpaDetailsProvider == null ? null : jpaDetailsProvider.buildDetailsPage(parent, widgetFactory); - } - - protected JpaDetailsProvider getDetailsProvider(JpaStructureNode structureNode) { - for (JpaDetailsProvider provider : CollectionTools.iterable(this.detailsProviders())) { - if (provider.providesDetails(structureNode)) { - return provider; - } - } - return null;//return null, some structure nodes do not have a details page - } - - protected ListIterator<JpaDetailsProvider> detailsProviders() { - return this.platformUiProvider.detailsProviders(); - } - - - // ********** mapping ui definitions ********** - - public JpaComposite buildTypeMappingComposite( - JptResourceType resourceType, - String mappingKey, - Composite parent, - PropertyValueModel<TypeMapping> mappingHolder, - WidgetFactory widgetFactory) { - - return getMappingResourceUiDefinition(resourceType).buildTypeMappingComposite( - mappingKey, mappingHolder, parent, widgetFactory); - } - - public JpaComposite buildAttributeMappingComposite( - JptResourceType resourceType, - String mappingKey, - Composite parent, - PropertyValueModel<AttributeMapping> mappingHolder, - WidgetFactory widgetFactory) { - - return getMappingResourceUiDefinition(resourceType).buildAttributeMappingComposite( - mappingKey, mappingHolder, parent, widgetFactory); - } - - public DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping> getDefaultAttributeMappingUiDefinition(JptResourceType resourceType, String mappingKey) { - return getMappingResourceUiDefinition(resourceType).getDefaultAttributeMappingUiDefinition(mappingKey); - } - - public Iterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>> attributeMappingUiDefinitions(JptResourceType resourceType) { - return getMappingResourceUiDefinition(resourceType).attributeMappingUiDefinitions(); - } - - public DefaultMappingUiDefinition<PersistentType, ? extends TypeMapping> getDefaultTypeMappingUiDefinition(JptResourceType resourceType) { - return getMappingResourceUiDefinition(resourceType).getDefaultTypeMappingUiDefinition(); - } - - public Iterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>> typeMappingUiDefinitions(JptResourceType resourceType) { - return getMappingResourceUiDefinition(resourceType).typeMappingUiDefinitions(); - } - - - // ********** resource ui definitions ********** - - protected ListIterator<ResourceUiDefinition> resourceUiDefinitions() { - return this.platformUiProvider.resourceUiDefinitions(); - } - - public ResourceUiDefinition getResourceUiDefinition(JptResourceType resourceType) { - for (ResourceUiDefinition definition : CollectionTools.iterable(this.resourceUiDefinitions())) { - if (definition.providesUi(resourceType)) { - return definition; - } - } - // TODO (bug 313632) - return a null resource ui definition? - throw new IllegalArgumentException("No resource UI definition for the resource type: " + resourceType); //$NON-NLS-1$ - } - - public MappingResourceUiDefinition getMappingResourceUiDefinition(JptResourceType resourceType) { - ResourceUiDefinition def = this.getResourceUiDefinition(resourceType); - try { - return (MappingResourceUiDefinition) def; - } catch (ClassCastException cce) { - // TODO (bug 313632) - return a null resource ui definition? - throw new IllegalArgumentException("No mapping resource UI definition for the resource type: " + resourceType, cce); //$NON-NLS-1$ - } - } - - - // ********** entity generation ********** - - public void generateEntities(JpaProject project, IStructuredSelection selection) { - EntitiesGenerator.generate(project, selection); - } - - - // ********** convenience methods ********** - - protected void displayMessage(String title, String message) { - Shell currentShell = Display.getCurrent().getActiveShell(); - MessageDialog.openInformation(currentShell, title, message); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/EntitiesGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/EntitiesGenerator.java deleted file mode 100644 index 76591440ac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/EntitiesGenerator.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.platform.base; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.ui.internal.wizards.gen.GenerateEntitiesFromSchemaWizard; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * EntitiesGenerator - */ -public class EntitiesGenerator { - private JpaProject project; - private IStructuredSelection selection; - - public static void generate(JpaProject project, IStructuredSelection selection) { - new EntitiesGenerator(project, selection).generate(); - } - - private EntitiesGenerator(JpaProject project, IStructuredSelection selection) { - super(); - if (project == null) { - throw new NullPointerException(); - } - this.project = project; - this.selection = selection; - } - - - // ********** generate ********** - - /** - * prompt the user with a wizard; - * schedule a job to generate the entities; - * optionally schedule a job to synchronize persistence.xml to - * run afterwards - */ - protected void generate() { - GenerateEntitiesFromSchemaWizard wizard = new GenerateEntitiesFromSchemaWizard(this.project, this.selection); - WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard); - dialog.create(); - int returnCode = dialog.open(); - if (returnCode != Window.OK) { - return; - } - //Entities generation happens in the GenerateEntitiesFromSchemaWizard.performFinish() - //method - } - - private Shell getCurrentShell() { - return Display.getCurrent().getActiveShell(); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ClassRefItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ClassRefItemLabelProvider.java deleted file mode 100644 index f2b488aca9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ClassRefItemLabelProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class ClassRefItemLabelProvider extends AbstractItemLabelProvider -{ - public ClassRefItemLabelProvider( - ClassRef classRef, DelegatingContentAndLabelProvider labelProvider) { - super(classRef, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - Image image; - if (((ClassRef) model()).isVirtual()) { - image = JptUiIcons.ghost(JptUiIcons.CLASS_REF); - } - else { - image = JptJpaUiPlugin.getImage(JptUiIcons.CLASS_REF); - } - return new StaticPropertyValueModel<Image>(image); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new PropertyAspectAdapter<ClassRef, String>(ClassRef.CLASS_NAME_PROPERTY, (ClassRef) model()) { - @Override - protected String buildValue_() { - return subject.getClassName(); - } - }; - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - //TODO also need to listen to the PersistenceUnit name property since this value depends on it - return new PropertyAspectAdapter<ClassRef, String>(ClassRef.CLASS_NAME_PROPERTY, (ClassRef) model()) { - @Override - protected String buildValue_() { - return subject.getPersistenceUnit().getName() - + "/\"" + subject.getClassName() - + "\" - " + subject.getResource().getFullPath().makeRelative(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/EntityMappingsItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/EntityMappingsItemLabelProvider.java deleted file mode 100644 index 0d28953cc3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/EntityMappingsItemLabelProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.graphics.Image; - -public class EntityMappingsItemLabelProvider extends AbstractItemLabelProvider -{ - public EntityMappingsItemLabelProvider( - EntityMappings entityMappings, DelegatingContentAndLabelProvider labelProvider) { - super(entityMappings, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>( - JptJpaUiPlugin.getImage(JptUiIcons.ENTITY_MAPPINGS)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>( - JptUiMessages.OrmItemLabelProviderFactory_entityMappingsLabel); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new StaticPropertyValueModel<String>( - JptUiMessages.OrmItemLabelProviderFactory_entityMappingsLabel - + " - " + ((EntityMappings) model()).getResource().getFullPath().makeRelative()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java deleted file mode 100644 index d0baf65cac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.platform.base.BaseJpaPlatformUi; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; - -public class GenericJpaPlatformUi - extends BaseJpaPlatformUi -{ - public GenericJpaPlatformUi( - JpaNavigatorProvider navigatorProvider, JpaPlatformUiProvider platformUiProvider) { - - super(navigatorProvider, platformUiProvider); - } - - - // ********** DDL generation ********** - - public void generateDDL(JpaProject project, IStructuredSelection selection) { - this.displayMessage(JptUiMessages.GenericPlatformUiDialog_notSupportedMessageTitle, JptUiMessages.GenericPlatformUiDialog_notSupportedMessageText); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUiFactory.java deleted file mode 100644 index 263287fe77..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUiFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JpaPlatformUiFactory; -import org.eclipse.jpt.jpa.ui.internal.GenericJpaPlatformUiProvider; - -public class GenericJpaPlatformUiFactory implements JpaPlatformUiFactory -{ - - /** - * Zero arg constructor for extension point - */ - public GenericJpaPlatformUiFactory() { - super(); - } - - public JpaPlatformUi buildJpaPlatformUi() { - return new GenericJpaPlatformUi( - new GenericNavigatorProvider(), - GenericJpaPlatformUiProvider.instance() - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java deleted file mode 100644 index e7475f8cd9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java +++ /dev/null @@ -1,255 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.platform.generic; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -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.FilteringCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationListValueModel; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.MappingFile; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JarFile; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmXml; -import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; -import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; - -public class GenericNavigatorItemContentProviderFactory - implements TreeItemContentProviderFactory -{ - public TreeItemContentProvider buildItemContentProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - DelegatingTreeContentAndLabelProvider treeContentAndLabelProvider = (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider; - - if (item instanceof JpaRootContextNode) { - return new RootContextItemContentProvider((JpaRootContextNode) item, treeContentAndLabelProvider); - } - else if (item instanceof PersistenceXml) { - return new PersistenceXmlItemContentProvider((PersistenceXml) item, treeContentAndLabelProvider); - } - else if (item instanceof PersistenceUnit) { - return new PersistenceUnitItemContentProvider((PersistenceUnit) item, treeContentAndLabelProvider); - } - else if (item instanceof OrmXml) { - return new OrmXmlItemContentProvider((OrmXml) item, treeContentAndLabelProvider); - } - else if (item instanceof OrmPersistentType) { - return new OrmPersistentTypeItemContentProvider((OrmPersistentType) item, treeContentAndLabelProvider); - } - else if (item instanceof JavaPersistentType) { - return new JavaPersistentTypeItemContentProvider((JavaPersistentType) item, treeContentAndLabelProvider); - } - else if (item instanceof PersistentAttribute) { - return new PersistentAttributeItemContentProvider((PersistentAttribute) item, treeContentAndLabelProvider); - } - return null; - } - - - public static class PersistenceUnitItemContentProvider extends AbstractTreeItemContentProvider<JpaContextNode> - { - public PersistenceUnitItemContentProvider( - PersistenceUnit persistenceUnit, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistenceUnit, contentProvider); - } - - @Override - public PersistenceUnit getModel() { - return (PersistenceUnit) super.getModel(); - } - - @Override - public PersistenceXml getParent() { - return getModel().getParent().getParent(); - } - - @Override - protected CollectionValueModel<JpaContextNode> buildChildrenModel() { - List<CollectionValueModel<? extends JpaContextNode>> list = new ArrayList<CollectionValueModel<? extends JpaContextNode>>(); - list.add(buildSpecifiedOrmXmlCvm()); - list.add(buildImpliedMappingFileCvm()); - list.add(buildPersistentTypeCvm()); - list.add(buildJarFileCvm()); - return new CompositeCollectionValueModel<CollectionValueModel<? extends JpaContextNode>, JpaContextNode>(list); - } - - protected CollectionValueModel<JpaContextNode> buildSpecifiedOrmXmlCvm() { - return new FilteringCollectionValueModel<JpaContextNode>( - new ListCollectionValueModelAdapter<MappingFile>( - new TransformationListValueModel<MappingFileRef, MappingFile>( - new ItemPropertyListValueModelAdapter<MappingFileRef>( - new ListAspectAdapter<PersistenceUnit, MappingFileRef>( - PersistenceUnit.SPECIFIED_MAPPING_FILE_REFS_LIST, - getModel()) { - @Override - protected ListIterator<MappingFileRef> listIterator_() { - return subject.specifiedMappingFileRefs(); - } - @Override - protected int size_() { - return subject.specifiedMappingFileRefsSize(); - } - }, MappingFileRef.MAPPING_FILE_PROPERTY)) { - @Override - protected MappingFile transformItem(MappingFileRef item) { - return item.getMappingFile(); - } - })) { - @Override - protected Iterable<JpaContextNode> filter(Iterable<? extends JpaContextNode> items) { - return new FilteringIterable<JpaContextNode>(items) { - @Override - protected boolean accept(JpaContextNode o) { - return o != null; - } - }; - } - }; - } - - protected CollectionValueModel<MappingFile> buildImpliedMappingFileCvm() { - return new PropertyCollectionValueModelAdapter<MappingFile>( - new PropertyAspectAdapter<MappingFileRef, MappingFile>( - new PropertyAspectAdapter<PersistenceUnit, MappingFileRef>( - PersistenceUnit.IMPLIED_MAPPING_FILE_REF_PROPERTY, - getModel()) { - @Override - protected MappingFileRef buildValue_() { - return subject.getImpliedMappingFileRef(); - } - }, - MappingFileRef.MAPPING_FILE_PROPERTY) { - @Override - protected MappingFile buildValue_() { - return subject.getMappingFile(); - } - } - ); - } - - protected CollectionValueModel<JpaContextNode> buildPersistentTypeCvm() { - return new FilteringCollectionValueModel<JpaContextNode>( - new ListCollectionValueModelAdapter<PersistentType>( - new TransformationListValueModel<ClassRef, PersistentType>( - new ItemPropertyListValueModelAdapter<ClassRef>(buildClassRefCvm(), ClassRef.JAVA_PERSISTENT_TYPE_PROPERTY)) { - @Override - protected PersistentType transformItem(ClassRef item) { - return item.getJavaPersistentType(); - } - })) { - @Override - protected Iterable<JpaContextNode> filter(Iterable<? extends JpaContextNode> items) { - return new FilteringIterable<JpaContextNode>(items) { - @Override - protected boolean accept(JpaContextNode o) { - return o != null; - } - }; - } - }; - } - - protected CollectionValueModel<ClassRef> buildClassRefCvm() { - ArrayList<CollectionValueModel<ClassRef>> holders = new ArrayList<CollectionValueModel<ClassRef>>(2); - holders.add(buildSpecifiedClassRefCvm()); - holders.add(buildImpliedClassRefCvm()); - return new CompositeCollectionValueModel<CollectionValueModel<ClassRef>, ClassRef>(holders); - } - - protected CollectionValueModel<ClassRef> buildSpecifiedClassRefCvm() { - return new ListCollectionValueModelAdapter<ClassRef>( - new ListAspectAdapter<PersistenceUnit, ClassRef>( - PersistenceUnit.SPECIFIED_CLASS_REFS_LIST, getModel()) { - @Override - protected ListIterator<ClassRef> listIterator_() { - return subject.specifiedClassRefs(); - } - @Override - protected int size_() { - return subject.specifiedClassRefsSize(); - } - }); - } - - protected CollectionValueModel<ClassRef> buildImpliedClassRefCvm() { - return new CollectionAspectAdapter<PersistenceUnit, ClassRef>( - PersistenceUnit.IMPLIED_CLASS_REFS_COLLECTION, getModel()) { - @Override - protected Iterator<ClassRef> iterator_() { - return subject.impliedClassRefs(); - } - @Override - protected int size_() { - return subject.impliedClassRefsSize(); - } - }; - } - - protected CollectionValueModel<JpaContextNode> buildJarFileCvm() { - return new FilteringCollectionValueModel<JpaContextNode>( - new ListCollectionValueModelAdapter<JarFile>( - new TransformationListValueModel<JarFileRef, JarFile>( - new ItemPropertyListValueModelAdapter<JarFileRef>(buildJarFileRefCvm(), JarFileRef.JAR_FILE_PROPERTY)) { - @Override - protected JarFile transformItem(JarFileRef item) { - return item.getJarFile(); - } - })) { - @Override - protected Iterable<JpaContextNode> filter(Iterable<? extends JpaContextNode> items) { - return new FilteringIterable<JpaContextNode>(items) { - @Override - protected boolean accept(JpaContextNode o) { - return o != null; - } - }; - } - }; - } - - protected CollectionValueModel<JarFileRef> buildJarFileRefCvm() { - return new ListCollectionValueModelAdapter<JarFileRef>( - new ListAspectAdapter<PersistenceUnit, JarFileRef>( - PersistenceUnit.JAR_FILE_REFS_LIST, getModel()) { - @Override - protected ListIterator<JarFileRef> listIterator_() { - return subject.jarFileRefs(); - } - @Override - protected int size_() { - return subject.jarFileRefsSize(); - } - }); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java deleted file mode 100644 index f3063b5be2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JarFile; -import org.eclipse.jpt.jpa.core.context.orm.OrmXml; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.ui.internal.jface.JarFileItemLabelProvider; - -public class GenericNavigatorItemLabelProviderFactory - implements ItemLabelProviderFactory -{ - public ItemLabelProvider buildItemLabelProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - if (item instanceof JpaRootContextNode) { - return new RootContextItemLabelProvider((JpaRootContextNode) item, contentAndLabelProvider); - } - else if (item instanceof PersistenceXml) { - return new PersistenceXmlItemLabelProvider((PersistenceXml) item, contentAndLabelProvider); - } - else if (item instanceof PersistenceUnit) { - return new PersistenceUnitItemLabelProvider((PersistenceUnit) item, contentAndLabelProvider); - } - else if (item instanceof OrmXml) { - return new OrmXmlItemLabelProvider((OrmXml) item, contentAndLabelProvider); - } - else if (item instanceof PersistentType) { - return new PersistentTypeItemLabelProvider((PersistentType) item, contentAndLabelProvider); - } - else if (item instanceof PersistentAttribute) { - return new PersistentAttributeItemLabelProvider((PersistentAttribute) item, contentAndLabelProvider); - } - else if (item instanceof JarFile) { - return new JarFileItemLabelProvider((JarFile) item, contentAndLabelProvider); - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorProvider.java deleted file mode 100644 index a1d3997bf3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jpa.ui.navigator.JpaNavigatorProvider; - -public class GenericNavigatorProvider implements JpaNavigatorProvider -{ - public ItemLabelProviderFactory getItemLabelProviderFactory() { - return new GenericNavigatorItemLabelProviderFactory(); - } - - public TreeItemContentProviderFactory getTreeItemContentProviderFactory() { - return new GenericNavigatorItemContentProviderFactory(); - } - - public void dispose() { - // TODO Auto-generated method stub - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/JarFileRefItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/JarFileRefItemLabelProvider.java deleted file mode 100644 index c21c58fb9b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/JarFileRefItemLabelProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class JarFileRefItemLabelProvider extends AbstractItemLabelProvider -{ - public JarFileRefItemLabelProvider( - JarFileRef jarFileRef, DelegatingContentAndLabelProvider labelProvider) { - super(jarFileRef, labelProvider); - } - - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new PropertyAspectAdapter<JarFileRef, String>(JarFileRef.FILE_NAME_PROPERTY, (JarFileRef) model()) { - @Override - protected String buildValue_() { - return subject.getFileName(); - } - }; - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.JAR_FILE_REF)); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new PropertyAspectAdapter<JarFileRef, String>(JarFileRef.FILE_NAME_PROPERTY, (JarFileRef) model()) { - @Override - protected String buildValue_() { - return subject.getPersistenceUnit().getName() - + "/\"" + subject.getFileName() - + "\" - " + subject.getResource().getFullPath().makeRelative(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java deleted file mode 100644 index 436dc21c86..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.platform.generic; - -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; - -public class JavaPersistentTypeItemContentProvider extends AbstractTreeItemContentProvider<JavaPersistentAttribute> -{ - public JavaPersistentTypeItemContentProvider( - JavaPersistentType persistentType, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistentType, contentProvider); - } - - @Override - public JavaPersistentType getModel() { - return (JavaPersistentType) super.getModel(); - } - - @Override - public Object getParent() { - return getModel().getParent(); - } - - @Override - protected CollectionValueModel<JavaPersistentAttribute> buildChildrenModel() { - return new ListCollectionValueModelAdapter<JavaPersistentAttribute>( - new ListAspectAdapter<JavaPersistentType, JavaPersistentAttribute>(JavaPersistentType.ATTRIBUTES_LIST, getModel()) { - @Override - protected ListIterator<JavaPersistentAttribute> listIterator_() { - return subject.attributes(); - } - - @Override - protected int size_() { - return subject.attributesSize(); - } - }); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/MappingFileRefItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/MappingFileRefItemLabelProvider.java deleted file mode 100644 index bf1af296e0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/MappingFileRefItemLabelProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class MappingFileRefItemLabelProvider extends AbstractItemLabelProvider -{ - public MappingFileRefItemLabelProvider( - MappingFileRef mappingFileRef, DelegatingContentAndLabelProvider labelProvider) { - super(mappingFileRef, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - Image image; - if (((MappingFileRef) model()).isImplied()) { - image = JptUiIcons.ghost(JptUiIcons.MAPPING_FILE_REF); - } - else { - image = JptJpaUiPlugin.getImage(JptUiIcons.MAPPING_FILE_REF); - } - return new StaticPropertyValueModel<Image>(image); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new PropertyAspectAdapter<MappingFileRef, String>(MappingFileRef.FILE_NAME_PROPERTY, (MappingFileRef) model()) { - @Override - protected String buildValue_() { - return subject.getFileName(); - } - }; - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new PropertyAspectAdapter<MappingFileRef, String>(MappingFileRef.FILE_NAME_PROPERTY, (MappingFileRef) model()) { - @Override - protected String buildValue_() { - return subject.getPersistenceUnit().getName() - + "/\"" + subject.getFileName() + "\"" - + " - " + subject.getResource().getFullPath().makeRelative(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java deleted file mode 100644 index 34e16ca326..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.platform.generic; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; - -public class OrmPersistentTypeItemContentProvider - extends AbstractTreeItemContentProvider<OrmReadOnlyPersistentAttribute> -{ - public OrmPersistentTypeItemContentProvider( - OrmPersistentType persistentType, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistentType, contentProvider); - } - - @Override - public OrmPersistentType getModel() { - return (OrmPersistentType) super.getModel(); - } - - @Override - public Object getParent() { - return getModel().getParent(); - } - - @Override - protected CollectionValueModel<OrmReadOnlyPersistentAttribute> buildChildrenModel() { - List<CollectionValueModel<OrmReadOnlyPersistentAttribute>> list = new ArrayList<CollectionValueModel<OrmReadOnlyPersistentAttribute>>(2); - list.add(buildSpecifiedPersistentAttributesModel()); - list.add(buildVirtualPersistentAttributesModel()); - return new CompositeCollectionValueModel<CollectionValueModel<OrmReadOnlyPersistentAttribute>, OrmReadOnlyPersistentAttribute>(list); - } - - protected CollectionValueModel<OrmReadOnlyPersistentAttribute> buildSpecifiedPersistentAttributesModel() { - return new ListCollectionValueModelAdapter<OrmReadOnlyPersistentAttribute>( - new ListAspectAdapter<OrmPersistentType, OrmReadOnlyPersistentAttribute>(OrmPersistentType.SPECIFIED_ATTRIBUTES_LIST, getModel()) { - @Override - protected ListIterator<OrmReadOnlyPersistentAttribute> listIterator_() { - return new SuperListIteratorWrapper<OrmReadOnlyPersistentAttribute>(this.specifiedAttributes()); - } - protected ListIterator<OrmPersistentAttribute> specifiedAttributes() { - return this.subject.specifiedAttributes(); - } - @Override - protected int size_() { - return this.subject.specifiedAttributesSize(); - } - }); - } - - protected CollectionValueModel<OrmReadOnlyPersistentAttribute> buildVirtualPersistentAttributesModel() { - return new ListCollectionValueModelAdapter<OrmReadOnlyPersistentAttribute>( - new ListAspectAdapter<OrmPersistentType, OrmReadOnlyPersistentAttribute>(OrmPersistentType.VIRTUAL_ATTRIBUTES_LIST, getModel()) { - @Override - protected ListIterator<OrmReadOnlyPersistentAttribute> listIterator_() { - return subject.virtualAttributes(); - } - @Override - protected int size_() { - return subject.virtualAttributesSize(); - } - }); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java deleted file mode 100644 index 7e29fc2532..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmXml; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; - -public class OrmXmlItemContentProvider - extends AbstractTreeItemContentProvider<OrmPersistentType> -{ - public OrmXmlItemContentProvider( - OrmXml ormXml, DelegatingTreeContentAndLabelProvider contentProvider) { - super(ormXml, contentProvider); - } - - @Override - public OrmXml getModel() { - return (OrmXml) super.getModel(); - } - - @Override - public PersistenceUnit getParent() { - return getModel().getPersistenceUnit(); - } - - @Override - protected CollectionValueModel<OrmPersistentType> buildChildrenModel() { - return new ListCollectionValueModelAdapter<OrmPersistentType>( - new ListAspectAdapter<EntityMappings, OrmPersistentType>( - buildEntityMappingsHolder(), - EntityMappings.PERSISTENT_TYPES_LIST) { - @Override - protected ListIterable<OrmPersistentType> getListIterable() { - return subject.getPersistentTypes(); - } - @Override - protected int size_() { - return subject.getPersistentTypesSize(); - } - }); - } - - protected PropertyValueModel<EntityMappings> buildEntityMappingsHolder() { - return new PropertyAspectAdapter<OrmXml, EntityMappings>( - OrmXml.ROOT_PROPERTY, getModel()) { - @Override - protected EntityMappings buildValue_() { - return subject.getRoot(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemLabelProvider.java deleted file mode 100644 index 2593c4dadb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemLabelProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.orm.OrmXml; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class OrmXmlItemLabelProvider extends AbstractItemLabelProvider -{ - public OrmXmlItemLabelProvider( - OrmXml ormXml, DelegatingContentAndLabelProvider labelProvider) { - super(ormXml, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.JPA_FILE)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(((OrmXml) model()).getResource().getName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - OrmXml ormXml = (OrmXml) model(); - return new StaticPropertyValueModel<String>( - ormXml.getResource().getName() - + " - " + ormXml.getResource().getParent().getFullPath().makeRelative().toString()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceItemLabelProvider.java deleted file mode 100644 index c3706213e7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceItemLabelProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.graphics.Image; - -public class PersistenceItemLabelProvider extends AbstractItemLabelProvider -{ - public PersistenceItemLabelProvider( - Persistence persistence, DelegatingContentAndLabelProvider labelProvider) { - super(persistence, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.PERSISTENCE)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>( - JptUiMessages.PersistenceItemLabelProviderFactory_persistenceLabel); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new StaticPropertyValueModel<String>( - JptUiMessages.PersistenceItemLabelProviderFactory_persistenceLabel - + " - " + ((Persistence) model()).getResource().getFullPath().makeRelative()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemLabelProvider.java deleted file mode 100644 index eaa8423760..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemLabelProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class PersistenceUnitItemLabelProvider extends AbstractItemLabelProvider -{ - public PersistenceUnitItemLabelProvider( - PersistenceUnit persistenceUnit, DelegatingContentAndLabelProvider labelProvider) { - super(persistenceUnit, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.PERSISTENCE_UNIT)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new PropertyAspectAdapter<PersistenceUnit, String>(PersistenceUnit.NAME_PROPERTY, (PersistenceUnit) model()) { - @Override - protected String buildValue_() { - return subject.getName(); - } - }; - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new PropertyAspectAdapter<PersistenceUnit, String>(PersistenceUnit.NAME_PROPERTY, (PersistenceUnit) model()) { - @Override - protected String buildValue_() { - return subject.getName() - + " - " + subject.getResource().getFullPath().makeRelative(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java deleted file mode 100644 index 7e8ebbaf5b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import java.util.ListIterator; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; - -public class PersistenceXmlItemContentProvider - extends AbstractTreeItemContentProvider<PersistenceUnit> -{ - public PersistenceXmlItemContentProvider( - PersistenceXml persistenceXml, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistenceXml, contentProvider); - } - - @Override - public PersistenceXml getModel() { - return (PersistenceXml) super.getModel(); - } - - @Override - public JpaRootContextNode getParent() { - return (JpaRootContextNode) getModel().getParent(); - } - - @Override - protected CollectionValueModel<PersistenceUnit> buildChildrenModel() { - return new ListCollectionValueModelAdapter<PersistenceUnit>( - new ListAspectAdapter<Persistence, PersistenceUnit>( - new PropertyAspectAdapter<PersistenceXml, Persistence>( - PersistenceXml.PERSISTENCE_PROPERTY, getModel()) { - @Override - protected Persistence buildValue_() { - return subject.getPersistence(); - } - }, - Persistence.PERSISTENCE_UNITS_LIST) { - @Override - protected ListIterator<PersistenceUnit> listIterator_() { - return subject.persistenceUnits(); - } - }); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemLabelProvider.java deleted file mode 100644 index 3e6220ca59..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemLabelProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class PersistenceXmlItemLabelProvider extends AbstractItemLabelProvider -{ - public PersistenceXmlItemLabelProvider( - PersistenceXml persistenceXml, DelegatingContentAndLabelProvider labelProvider) { - super(persistenceXml, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.JPA_FILE)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(((PersistenceXml) model()).getResource().getName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - PersistenceXml persistenceXml = (PersistenceXml) model(); - return new StaticPropertyValueModel<String>( - persistenceXml.getResource().getName() - + " - " + persistenceXml.getResource().getParent().getFullPath().makeRelative().toString()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentAttributeItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentAttributeItemContentProvider.java deleted file mode 100644 index bdde1fde4e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentAttributeItemContentProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; - -@SuppressWarnings("unchecked") -public class PersistentAttributeItemContentProvider extends AbstractTreeItemContentProvider -{ - public PersistentAttributeItemContentProvider( - PersistentAttribute persistentAttribute, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistentAttribute, contentProvider); - } - - @Override - public PersistentAttribute getModel() { - return (PersistentAttribute) super.getModel(); - } - - @Override - public Object getParent() { - return getModel().getParent(); - } - - @Override - public boolean hasChildren() { - return false; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentAttributeItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentAttributeItemLabelProvider.java deleted file mode 100644 index 213a1b1c86..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentAttributeItemLabelProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.platform.generic; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.swt.graphics.Image; - -public class PersistentAttributeItemLabelProvider - extends AbstractItemLabelProvider -{ - public PersistentAttributeItemLabelProvider( - ReadOnlyPersistentAttribute persistentAttribute, DelegatingContentAndLabelProvider labelProvider) { - super(persistentAttribute, labelProvider); - } - - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new PropertyAspectAdapter<ReadOnlyPersistentAttribute, Image>( - new String[] {ReadOnlyPersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY, ReadOnlyPersistentAttribute.MAPPING_PROPERTY}, - (ReadOnlyPersistentAttribute) model()) { - @Override - protected Image buildValue_() { - if (((ReadOnlyPersistentAttribute) model()).isVirtual()) { - return JptUiIcons.ghost(JpaMappingImageHelper.iconKeyForAttributeMapping(this.subject.getMappingKey())); - } - return JpaMappingImageHelper.imageForAttributeMapping(this.subject.getMappingKey()); - } - }; - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new PropertyAspectAdapter<ReadOnlyPersistentAttribute, String>(ReadOnlyPersistentAttribute.NAME_PROPERTY, (ReadOnlyPersistentAttribute) model()) { - @Override - protected String buildValue_() { - return subject.getName(); - } - }; - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new PropertyAspectAdapter<ReadOnlyPersistentAttribute, String>(ReadOnlyPersistentAttribute.NAME_PROPERTY, (ReadOnlyPersistentAttribute) model()) { - @Override - protected String buildValue_() { - StringBuilder sb = new StringBuilder(); - sb.append(this.subject.getPersistenceUnit().getName()); - sb.append('/'); - sb.append(this.subject.getOwningPersistentType().getName()); - sb.append('/'); - sb.append(this.subject.getName()); - IResource resource = this.subject.getResource(); - if (resource != null) { - sb.append(" - "); //$NON-NLS-1$ - sb.append(resource.getFullPath().makeRelative()); - } - return sb.toString(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java deleted file mode 100644 index 5541917411..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.jpa.ui.internal.platform.generic; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public class PersistentTypeItemLabelProvider extends AbstractItemLabelProvider -{ - public PersistentTypeItemLabelProvider( - PersistentType persistentType, DelegatingContentAndLabelProvider labelProvider) { - super(persistentType, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new PropertyAspectAdapter<PersistentType, Image>(PersistentType.MAPPING_PROPERTY, (PersistentType) model()) { - @Override - protected Image buildValue_() { - return JpaMappingImageHelper.imageForTypeMapping(subject.getMappingKey()); - } - }; - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new PropertyAspectAdapter<PersistentType, String>(PersistentType.NAME_PROPERTY, (PersistentType) model()) { - @Override - protected String buildValue_() { - return subject.getSimpleName(); - } - }; - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new PropertyAspectAdapter<PersistentType, String>(PersistentType.NAME_PROPERTY, (PersistentType) model()) { - @Override - protected String buildValue_() { - StringBuilder sb = new StringBuilder(); - sb.append(this.subject.getPersistenceUnit().getName()); - sb.append('/'); - sb.append(this.subject.getName()); - IResource resource = this.subject.getResource(); - if (resource != null) { - sb.append(" - "); //$NON-NLS-1$ - sb.append(resource.getFullPath().makeRelative()); - } - return sb.toString(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/RootContextItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/RootContextItemContentProvider.java deleted file mode 100644 index ef65255289..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/RootContextItemContentProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; - -public class RootContextItemContentProvider - extends AbstractTreeItemContentProvider<PersistenceXml> -{ - public RootContextItemContentProvider( - JpaRootContextNode rootContext, DelegatingTreeContentAndLabelProvider contentProvider) { - super(rootContext, contentProvider); - } - - @Override - public JpaRootContextNode getModel() { - return (JpaRootContextNode) super.getModel(); - } - - @Override - public IProject getParent() { - return getModel().getJpaProject().getProject(); - } - - @Override - protected CollectionValueModel<PersistenceXml> buildChildrenModel() { - return new PropertyCollectionValueModelAdapter<PersistenceXml>( - new PropertyAspectAdapter<JpaRootContextNode, PersistenceXml>( - JpaRootContextNode.PERSISTENCE_XML_PROPERTY, - getModel()) { - @Override - protected PersistenceXml buildValue_() { - return subject.getPersistenceXml(); - } - }); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/RootContextItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/RootContextItemLabelProvider.java deleted file mode 100644 index d00996f6c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/RootContextItemLabelProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.graphics.Image; - -public class RootContextItemLabelProvider extends AbstractItemLabelProvider -{ - public RootContextItemLabelProvider( - JpaRootContextNode rootContextNode, DelegatingContentAndLabelProvider labelProvider) { - super(rootContextNode, labelProvider); - } - - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJpaUiPlugin.getImage(JptUiIcons.JPA_CONTENT)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(JptUiMessages.JpaContent_label); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new StaticPropertyValueModel<String>( - JptUiMessages.JpaContent_label - + " - " + ((JpaRootContextNode) model()).getResource().getFullPath().makeRelative()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java deleted file mode 100644 index 743281463a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaPreferencesPage.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.preferences; - -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * This is the root of the Java Persistence preferences hierarchy in the IDE - * preferences dialog. - * <p> - * Structure: - * <p> - * Java Persistence<br> - * |- Errors/Warnings - * - * @version 2.2 - * @since 2.2 - */ -public class JpaPreferencesPage extends PreferencePage - implements IWorkbenchPreferencePage { - - /** - * Creates a new <code>JpaPreferencesPage</code>. - */ - public JpaPreferencesPage() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - protected Control createContents(Composite parent) { - parent = new Composite(parent, SWT.NONE); - parent.setLayout(new GridLayout(1, false)); - - // Message label - Label label = new Label(parent, SWT.NONE); - label.setText(JptUiMessages.JpaPreferencesPage_Description); - label.setData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, true)); - - return parent; - } - - /** - * {@inheritDoc} - */ - public void init(IWorkbench workbench) { - setPreferenceStore(JptJpaUiPlugin.instance().getPreferenceStore()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java deleted file mode 100644 index 6dd7083534..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java +++ /dev/null @@ -1,941 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.preferences; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage; -import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationPreferences; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.JptUiValidationPreferenceMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.forms.events.ExpansionAdapter; -import org.eclipse.ui.forms.events.ExpansionEvent; -import org.eclipse.ui.forms.widgets.ExpandableComposite; - -/** - * This page shows the Java Persistence validation options. It supports - * workspace and project levels severities. - * - * @version 2.3 - * @since 2.2 - */ -@SuppressWarnings("restriction") -public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage { - - /** - * Severity level state is stored in this Map and is either committed or discarded - * based on user action. - * <br> key is the preferenceKey which is also the validation message key @see JpaValidationMessages. - * <br> value is a severity level - @see JpaValidationPreferences#ERROR WARNING INFO IGNORE - */ - private Map<String, String> severityLevels; - - /** - * Default severity levels are stored here, ERROR is the default default so only need - * to include WARNING, INFO, IGNORE in this Map. These will be displayed if neither the project - * or workspace preference applies. - * <br> key is the preferenceKey which is also the validation message key @see JpaValidationMessages. - * <br> value is a severity level - @see JpaValidationPreferences#ERROR WARNING INFO IGNORE - */ - private Map<String, String> defaultSeverities; - - /** - * The list of <code>Combo</code>s is cached in order to perform a revert of - * the properties. - */ - private List<Combo> combos; - - /** - * The list of <code>ExpandableComposite</code> is cached in order to save - * and restore the expansion state. - */ - private List<ExpandableComposite> expandablePanes; - - /** - * The position of the "Error" choice in the combo's model. - */ - private static final int ERROR_INDEX = 0; - - /** - * The position of the "Warning" choice in the combo's model. - */ - private static final int WARNING_INDEX = 1; - - /** - * The position of the "Info" choice in the combo's model. - */ - private static final int INFO_INDEX = 2; - - /** - * The position of the "Ignore" choice in the combo's model. - */ - private static final int IGNORE_INDEX = 3; - - /** - * The unique identifier for this page when it is shown in the IDE - * preferences dialog. - */ - private static final String JPT_PREFERENCES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.jpa.ui.jpaProblemSeveritiesPreferences"; //$NON-NLS-1$ - - /** - * The unique identifier for this page when it is shown in the project - * preferences dialog. - */ - private static final String JPT_PROPERTY_PAGES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.jpa.ui.jpaProblemSeveritiesProperties"; //$NON-NLS-1$ - - /** - * A constant used to store and retrieve the preference key (message ID) from - * the combo. - */ - private static final String PREFERENCE_KEY = "preferenceKey"; //$NON-NLS-1$ - - /** - * The scrollable pane used to show the content of this page. - */ - private ScrolledPageContent scrollable; - - /** - * The possible choices which describes the severity of a single problem. - */ - private String[] severityDisplayStrings; - - /** - * Constant used to store the expansion state of each expandable pane. - */ - public static final String SETTINGS_EXPANDED = "expanded"; //$NON-NLS-1$ - - /** - * The preference key used to retrieve the dialog settings where the expansion - * states have been stored. - */ - public static final String SETTINGS_SECTION_NAME = "JpaProblemSeveritiesPage"; //$NON-NLS-1$ - - private Boolean hasProjectSpecificPreferences = null; - - /** - * Creates a new <code>JpaProblemSeveritiesPage</code>. - */ - public JpaProblemSeveritiesPage() { - super(); - initialize(); - } - - @Override - public void init(IWorkbench workbench) { - this.setPreferenceStore(JptJpaUiPlugin.instance().getPreferenceStore()); - this.setDescription(JptUiMessages.JpaProblemSeveritiesPage_Description); - } - - protected void initialize() { - this.combos = new ArrayList<Combo>(); - this.expandablePanes = new ArrayList<ExpandableComposite>(); - this.severityDisplayStrings = buildSeverityDisplayStrings(); - this.severityLevels = new HashMap<String, String>(); - this.defaultSeverities = buildDefaultSeverties(); - } - - //since most of our problems have a default severity of ERROR, we are just defining the WARNING, INFO, IGNORE cases - protected Map<String, String> buildDefaultSeverties() { - Map<String, String> defaultSeverities = new HashMap<String, String>(); - - defaultSeverities.put(JpaValidationMessages.PROJECT_NO_CONNECTION, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.PROJECT_INVALID_CONNECTION, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.PROJECT_INACTIVE_CONNECTION, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED, JpaValidationPreferences.WARNING); - defaultSeverities.put(JpaValidationMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS, JpaValidationPreferences.WARNING); - - defaultSeverities.put(JpaValidationMessages.XML_VERSION_NOT_LATEST, JpaValidationPreferences.INFO); - defaultSeverities.put(JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS, JpaValidationPreferences.INFO); - - return defaultSeverities; - } - - @Override - protected Control createPreferenceContent(Composite parent) { - - PixelConverter pixelConverter = new PixelConverter(parent); - - // Create a container because the caller will set the GridData and we need - // to change the heightHint of the first child and we also need to set the - // font otherwise the layout won't be calculated correctly - Composite container = new Composite(parent, SWT.NONE); - container.setFont(parent.getFont()); - GridLayout layout = new GridLayout(1, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - container.setLayout(layout); - - // Create the main composite of this page - this.scrollable = new ScrolledPageContent(container); - - GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); - gridData.heightHint = pixelConverter.convertHeightInCharsToPixels(20); - this.scrollable.setLayoutData(gridData); - - // Update the layout of the ScrolledPageContent's body - layout = new GridLayout(1, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - - parent = this.scrollable.getBody(); - parent.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); - parent.setLayout(layout); - - // Add each expandable category - addProjectLevelCategory(parent); - addPersistenceUnitLevelCategory(parent); - addTypeLevelCategory(parent); - addAttributeLevelCategory(parent); - addDatabaseCategory(parent); - addInheritanceStrategyCategory(parent); - addQueriesGeneratorsCategory(parent); - - // Restore the expansion states - restoreSectionExpansionStates(getDialogPreferences()); - - return container; - } - - protected void restoreSectionExpansionStates(IDialogSettings settings) { - for (int index = this.expandablePanes.size(); --index >= 0; ) { - ExpandableComposite expandablePane = this.expandablePanes.get(index); - - if (settings == null) { - // Only expand the first node by default - expandablePane.setExpanded(index == 0); - } - else { - expandablePane.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + index)); - } - } - } - - @Override - public Point computeSize() { - return this.doComputeSize(); - } - - private void addProjectLevelCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.PROJECT_LEVEL_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.NO_JPA_PROJECT, JpaValidationMessages.NO_JPA_PROJECT); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_NO_CONNECTION, JpaValidationMessages.PROJECT_NO_CONNECTION); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_INVALID_CONNECTION, JpaValidationMessages.PROJECT_INVALID_CONNECTION); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_INACTIVE_CONNECTION, JpaValidationMessages.PROJECT_INACTIVE_CONNECTION); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.XML_VERSION_NOT_LATEST, JpaValidationMessages.XML_VERSION_NOT_LATEST); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_NO_PERSISTENCE_XML, JpaValidationMessages.PROJECT_NO_PERSISTENCE_XML); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PROJECT_MULTIPLE_PERSISTENCE_XML, JpaValidationMessages.PROJECT_MULTIPLE_PERSISTENCE_XML); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_NO_PERSISTENCE_UNIT, JpaValidationMessages.PERSISTENCE_NO_PERSISTENCE_UNIT); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS, JpaValidationMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_XML_INVALID_CONTENT, JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT); - } - - private void addPersistenceUnitLevelCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_LEVEL_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE, JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT, JpaValidationMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE, JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE, JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE, JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_INVALID_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_INVALID_CLASS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_DUPLICATE_JAR_FILE, JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_JAR_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE, JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING, JpaValidationMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE, JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA, JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA); - } - - private void addTypeLevelCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.TYPE_LEVEL_CATEGORY); - - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, - JpaValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, - JpaValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS, - JpaValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS, - JpaValidationMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_NO_PK, - JpaValidationMessages.ENTITY_NO_PK); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.TYPE_MAPPING_FINAL_CLASS, - JpaValidationMessages.TYPE_MAPPING_FINAL_CLASS); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.TYPE_MAPPING_MEMBER_CLASS, - JpaValidationMessages.TYPE_MAPPING_MEMBER_CLASS); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR, - JpaValidationMessages.TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR, - JpaValidationMessages.TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR); - } - - private void addAttributeLevelCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.ATTRIBUTE_LEVEL_CATEGORY); - - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED - , JpaValidationMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_FINAL_GETTER, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_GETTER); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.MAPPING_UNRESOLVED_MAPPED_BY, - JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.MAPPING_INVALID_MAPPED_BY, - JpaValidationMessages.MAPPING_INVALID_MAPPED_BY); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES, - JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_NOT_DEFINED, - JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY, - JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.MAPS_ID_VALUE_NOT_SPECIFIED, - JpaValidationMessages.MAPS_ID_VALUE_NOT_SPECIFIED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.MAPS_ID_VALUE_NOT_RESOLVED, - JpaValidationMessages.MAPS_ID_VALUE_NOT_RESOLVED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.MAPS_ID_VALUE_INVALID, - JpaValidationMessages.MAPS_ID_VALUE_INVALID); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED, - JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED); - - parent = addSubExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_LEVEL_CATEGORY); - - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED); - } - - private void addDatabaseCategory(Composite parent) { - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.DATABASE_CATEGORY); - parent.setLayout(new GridLayout(1, false)); - - addTableCategory(parent); - addColumnCategory(parent); - addOverridesCategory(parent); - } - - private void addTableCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.TABLE_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_NAME, JpaValidationMessages.TABLE_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.SECONDARY_TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.SECONDARY_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.SECONDARY_TABLE_UNRESOLVED_NAME, JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.JOIN_TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.JOIN_TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_TABLE_UNRESOLVED_NAME, JpaValidationMessages.JOIN_TABLE_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLLECTION_TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.COLLECTION_TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLLECTION_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.COLLECTION_TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLLECTION_TABLE_UNRESOLVED_NAME, JpaValidationMessages.COLLECTION_TABLE_UNRESOLVED_NAME); - - parent = addSubExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_LEVEL_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_NAME); - } - - private void addColumnCategory(Composite parent) { - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.COLUMN_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_TABLE_NOT_VALID, JpaValidationMessages.COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_UNRESOLVED_TABLE, JpaValidationMessages.COLUMN_UNRESOLVED_TABLE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_UNRESOLVED_NAME, JpaValidationMessages.COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.INVERSE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.INVERSE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.INVERSE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.INVERSE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS,JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.ORDER_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.ORDER_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAP_KEY_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.MAP_KEY_COLUMN_TABLE_NOT_VALID); - - parent = addSubExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_LEVEL_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ORDER_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ORDER_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID); - } - - private void addOverridesCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.OVERRIDES_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.ATTRIBUTE_OVERRIDE_INVALID_NAME, JpaValidationMessages.ATTRIBUTE_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.ASSOCIATION_OVERRIDE_INVALID_NAME, JpaValidationMessages.ASSOCIATION_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS); - - - parent = addSubExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_LEVEL_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS); - } - - private void addInheritanceStrategyCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.INHERITANCE_CATEGORY); - - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.DISCRIMINATOR_COLUMN_UNRESOLVED_NAME, - JpaValidationMessages.DISCRIMINATOR_COLUMN_UNRESOLVED_NAME); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM, - JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM, - JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE, - JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE, - JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED, - JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED, - JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED, - JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED); - addLabeledCombo( - parent, JptUiValidationPreferenceMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED, - JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED); - } - - private void addQueriesGeneratorsCategory(Composite parent) { - - parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.QUERIES_GENERATORS_CATEGORY); - - addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATOR_DUPLICATE_NAME, JpaValidationMessages.GENERATOR_DUPLICATE_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR, JpaValidationMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR); - addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_DUPLICATE_NAME, JpaValidationMessages.QUERY_DUPLICATE_NAME); - } - - private Composite addExpandableSection(Composite parent, String text) { - return addExpandableSection(parent, text, new GridData(GridData.FILL, GridData.FILL, true, false)); - } - - private Composite addSubExpandableSection(Composite parent, String text) { - return addExpandableSection(parent, text, new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1)); - } - - /** - * Creates and adds to the given <code>Composite</code> an expandable pane - * where its content can be shown or hidden depending on the expansion state. - * - * @param parent The parent container - * @param text The title of the expandable section - * @return The container to which widgets can be added, which is a child of - * the expandable pane - */ - private Composite addExpandableSection(Composite parent, String text, GridData gridData) { - ExpandableComposite expandablePane = new ExpandableComposite( - parent, - SWT.NONE, - ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT - ); - - expandablePane.setText(text); - expandablePane.setExpanded(false); - expandablePane.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); - expandablePane.setLayoutData(gridData); - expandablePane.addExpansionListener(buildExpansionListener()); - - this.scrollable.adaptChild(expandablePane); - this.expandablePanes.add(expandablePane); - - parent = new Composite(expandablePane, SWT.NONE); - parent.setLayout(new GridLayout(2, false)); - expandablePane.setClient(parent); - - return parent; - } - - /** - * Creates and adds to the given parent a labeled combo where the possible - * choices are "Ignore", "Error" and "Warning". - * - * @param parent The parent to which the widgets are added - * @param labelText The text labelling the combo - * @param preferenceKey The key used to retrieve and to store the value - * associated with the validation problem - */ - private void addLabeledCombo(Composite parent, String labelText, String preferenceKey) { - Label label = new Label(parent, SWT.NONE); - label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - label.setText(labelText); - - Combo combo = new Combo(parent, SWT.READ_ONLY); - combo.setItems(this.severityDisplayStrings); - combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - combo.setData(PREFERENCE_KEY, preferenceKey); - combo.select(convertPreferenceKeyToComboIndex(preferenceKey)); - combo.addSelectionListener(buildComboSelectionListener()); - - this.scrollable.adaptChild(combo); - this.combos.add(combo); - } - - private SelectionListener buildComboSelectionListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - Combo combo = (Combo) e.widget; - String preferenceKey = (String) combo.getData(PREFERENCE_KEY); - String value = convertToPreferenceValue(combo.getSelectionIndex()); - JpaProblemSeveritiesPage.this.severityLevels.put(preferenceKey, value); - } - }; - } - - private ExpansionAdapter buildExpansionListener() { - return new ExpansionAdapter() { - @Override - public void expansionStateChanged(ExpansionEvent e) { - JpaProblemSeveritiesPage.this.expansionStateChanged(); - } - }; - } - - protected String[] buildSeverityDisplayStrings() { - String[] severities = new String[4]; - severities[ERROR_INDEX] = JptUiMessages.JpaProblemSeveritiesPage_Error; - severities[WARNING_INDEX] = JptUiMessages.JpaProblemSeveritiesPage_Warning; - severities[INFO_INDEX] = JptUiMessages.JpaProblemSeveritiesPage_Info; - severities[IGNORE_INDEX] = JptUiMessages.JpaProblemSeveritiesPage_Ignore; - return severities; - } - - protected int convertPreferenceKeyToComboIndex(String preferenceKey) { - return convertPreferenceValueToComboIndex(getPreferenceValue(preferenceKey)); - } - - protected String getPreferenceValue(String preferenceKey) { - String preference = null; - if (isProjectPreferencePage() && hasProjectSpecificOptions(getProject())) { //useProjectSettings() won't work since the page is being built - preference = JpaValidationPreferences.getProjectLevelProblemPreference(getProject(), preferenceKey); - } - else { - //don't get the workspace preference when the project has overridden workspace preferences - preference = JpaValidationPreferences.getWorkspaceLevelProblemPreference(preferenceKey); - } - if (preference == null) { - preference = getDefaultPreferenceValue(preferenceKey); - } - return preference; - } - - /** - * Return the default severity or ERROR if no default exists. - */ - protected String getDefaultPreferenceValue(String preferenceKey) { - String preference = this.defaultSeverities.get(preferenceKey); - return preference == null ? JpaValidationPreferences.ERROR : preference; - } - - protected int convertPreferenceValueToComboIndex(String preferenceValue) { - if (JpaValidationPreferences.ERROR.equals(preferenceValue)) { - return ERROR_INDEX; - } - if (JpaValidationPreferences.WARNING.equals(preferenceValue)) { - return WARNING_INDEX; - } - if (JpaValidationPreferences.INFO.equals(preferenceValue)) { - return INFO_INDEX; - } - if (JpaValidationPreferences.IGNORE.equals(preferenceValue)) { - return IGNORE_INDEX; - } - throw new IllegalStateException(); - } - - protected String convertToPreferenceValue(int selectionIndex) { - switch (selectionIndex) { - case ERROR_INDEX: return JpaValidationPreferences.ERROR; - case WARNING_INDEX: return JpaValidationPreferences.WARNING; - case INFO_INDEX: return JpaValidationPreferences.INFO; - case IGNORE_INDEX: return JpaValidationPreferences.IGNORE; - default: return null; - } - } - - /** - * Revalidates the layout in order to show or hide the vertical scroll bar - * after a section was either expanded or collapsed. This unfortunately does - * not happen automatically. - */ - protected void expansionStateChanged() { - this.scrollable.reflow(true); - } - - @Override - protected String getPreferencePageID() { - return JPT_PREFERENCES_PROBLEM_SEVERITIES_ID; - } - - @Override - protected String getPropertyPageID() { - return JPT_PROPERTY_PAGES_PROBLEM_SEVERITIES_ID; - } - - protected IEclipsePreferences getProjectPreferences(IProject project) { - return JptJpaCorePlugin.getProjectPreferences(project); - } - - @Override - protected boolean hasProjectSpecificOptions(IProject project) { - IEclipsePreferences projectPreferences = getProjectPreferences(project); - return projectPreferences.getBoolean(JpaValidationPreferences.WORKSPACE_PREFERENCES_OVERRIDEN, false); - } - - @Override - protected void performDefaults() { - super.performDefaults(); - //this call would be redundant on project preference page - bug in the JDT superclass - if (!isProjectPreferencePage()) { - revertToDefault(); - } - } - - @Override - protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { - super.enableProjectSpecificSettings(useProjectSpecificSettings); - if (getDefaultsButton() == null) { - //@Hack("If the defaults button is null the control is currently being built," + - // "otherwise the 'enable project specific settings' checkbox is being pressed") - return; - } - - this.hasProjectSpecificPreferences = Boolean.valueOf(useProjectSpecificSettings); - - //set all specified workspace preferences in the project preferences - if (useProjectSpecificSettings){ - this.overrideWorkspacePreferences(); - } - else {//remove any project specific settings if set to false - this.revertToDefault(); - } - } - - @Override - protected void noDefaultAndApplyButton() { - throw new IllegalStateException("Don't call this, see enableProjectSpecificSettings for the hack that looks for the defaultsButton being null"); //$NON-NLS-1$ - } - - protected void revertToDefault() { - for (Combo combo : this.combos) { - String preferenceKey = (String) combo.getData(PREFERENCE_KEY); - String preference = JpaValidationPreferences.getWorkspaceLevelProblemPreference(preferenceKey); - if (preference == null) { - preference = getDefaultPreferenceValue(preferenceKey); - } - combo.select(convertPreferenceValueToComboIndex(preference)); - //UI will show the defaults from the workspace, but set all preferences - //to null so they will be deleted from project preferences - this.severityLevels.put(preferenceKey, null); - } - } - - protected void overrideWorkspacePreferences() { - for (Combo combo : this.combos) { - String preferenceKey = (String) combo.getData(PREFERENCE_KEY); - String workspacePreference = JpaValidationPreferences.getWorkspaceLevelProblemPreference(preferenceKey); - String defaultPreference = getDefaultPreferenceValue(preferenceKey); - if (workspacePreference != null && !workspacePreference.equals(defaultPreference)) { - combo.select(convertPreferenceValueToComboIndex(workspacePreference)); - //silly combo doesn't fire a selection event, so we can't expect our listener to set this - this.severityLevels.put(preferenceKey, workspacePreference); - } - else { - combo.select(convertPreferenceValueToComboIndex(defaultPreference)); - } - } - } - - // ********** OK/Revert/Apply behavior ********** - - @Override - public boolean performOk() { - super.performOk(); - if (this.hasProjectSpecificPreferences != null) { - IEclipsePreferences projectPreferences = getProjectPreferences(getProject()); - if (this.hasProjectSpecificPreferences.booleanValue()) { - projectPreferences.putBoolean(JpaValidationPreferences.WORKSPACE_PREFERENCES_OVERRIDEN, true); - } - else { - projectPreferences.remove(JpaValidationPreferences.WORKSPACE_PREFERENCES_OVERRIDEN); - } - JpaValidationPreferences.flush(projectPreferences); - } - for (String validationPreferenceKey : this.severityLevels.keySet()) { - updatePreference(validationPreferenceKey, this.severityLevels.get(validationPreferenceKey)); - } - try { - // true=fork; false=uncancellable - this.buildOkProgressMonitorDialog().run(true, false, this.buildOkRunnableWithProgress()); - } - catch (InterruptedException ex) { - return false; - } - catch (InvocationTargetException ex) { - throw new RuntimeException(ex.getTargetException()); - } - - return true; - } - - protected void updatePreference(String preferenceKey, String value) { - if (isProjectPreferencePage()) { - JpaValidationPreferences.setProjectLevelProblemPreference(getProject(), preferenceKey, value); - } - else { - JpaValidationPreferences.setWorkspaceLevelProblemPreference(preferenceKey, value); - } - } - - private IRunnableContext buildOkProgressMonitorDialog() { - return new ProgressMonitorDialog(this.getShell()); - } - - private IRunnableWithProgress buildOkRunnableWithProgress() { - return new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IWorkspace ws = ResourcesPlugin.getWorkspace(); - try { - // the build we execute in #performOk_() locks the workspace root, - // so we need to use the workspace root as our scheduling rule here - ws.run( - JpaProblemSeveritiesPage.this.buildOkWorkspaceRunnable(), - ws.getRoot(), - IWorkspace.AVOID_UPDATE, - monitor - ); - } - catch (CoreException ex) { - throw new InvocationTargetException(ex); - } - } - }; - } - - IWorkspaceRunnable buildOkWorkspaceRunnable() { - return new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - JpaProblemSeveritiesPage.this.performOk_(monitor); - } - }; - } - - void performOk_(IProgressMonitor monitor) throws CoreException { - //if project is null this is a workspace preference page - if (this.getProject()==null) { - JavaPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, monitor); - } - else this.getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor); - } - - @Override - public void dispose() { - storeSectionExpansionStates(getDialogPreferences()); - super.dispose(); - } - - protected IDialogSettings getDialogPreferences() { - IDialogSettings rootSettings = JptJpaUiPlugin.instance().getDialogSettings(); - IDialogSettings settings = rootSettings.getSection(SETTINGS_SECTION_NAME); - if (settings == null) { - settings = rootSettings.addNewSection(SETTINGS_SECTION_NAME); - } - return settings; - } - - protected void storeSectionExpansionStates(IDialogSettings settings) { - for (int index = this.expandablePanes.size(); --index >= 0; ) { - ExpandableComposite expandablePane = this.expandablePanes.get(index); - settings.put(SETTINGS_EXPANDED + index, expandablePane.isExpanded()); - } - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/DataModelPropertyPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/DataModelPropertyPage.java deleted file mode 100644 index 0786ddb62a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/DataModelPropertyPage.java +++ /dev/null @@ -1,309 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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.jpa.ui.internal.properties; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper; -import org.eclipse.wst.common.frameworks.internal.ui.ValidationStatus; - -public abstract class DataModelPropertyPage - extends PropertyPage - implements Listener, IDataModelListener -{ - protected IDataModel model; - - private ValidationStatus status = new ValidationStatus(); - private Map validationMap; - private String[] validationPropertyNames; - private boolean isValidating = false; - - protected DataModelSynchHelper synchHelper; - - private String infopopID; - - - protected DataModelPropertyPage(IDataModel model) { - super(); - this.model = model; - model.addListener(this); - synchHelper = initializeSynchHelper(model); - } - - - /** - * @return - */ - public DataModelSynchHelper initializeSynchHelper(IDataModel dm) { - return new DataModelSynchHelper(dm); - } - - - @Override - protected Control createContents(Composite parent) { - Composite top = createTopLevelComposite(parent); - setupInfopop(top); - setDefaults(); - addListeners(); - initializeValidationProperties(); - return top; - } - - private void initializeValidationProperties() { - validationPropertyNames = getValidationPropertyNames(); - if (validationPropertyNames == null || validationPropertyNames.length == 0) - validationMap = Collections.EMPTY_MAP; - else { - validationMap = new HashMap(validationPropertyNames.length); - for (int i = 0; i < validationPropertyNames.length; i++) - validationMap.put(validationPropertyNames[i], new Integer(i)); - } - } - - /** - * Subclass should return the model property names that need to be validated on this page in the - * order that they should present their messages. - * - * @return - */ - protected abstract String[] getValidationPropertyNames(); - - /** - * Return the top level Composite for this page. - */ - protected abstract Composite createTopLevelComposite(Composite parent); - - /** - * Set up info pop hooks if set. - */ - protected void setupInfopop(Control parent) { - if (getInfopopID() != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, getInfopopID()); - } - - /** - * Setup the default values for this page. Subclasses should override to provide appropriate - * defaults. - */ - protected void setDefaults() { - restoreDefaultSettings(); - } - - /** - * Subclasses should implement this method if they have default settings that have been stored - * and need to be restored. - * - * @see storeDefaultSettings() - */ - protected void restoreDefaultSettings() { - } - - /** - * Add Listeners to controls at this point to avoid unnecessary events. Subclasses should - * override to add listeners to its controls. - */ - protected void addListeners() { - } - - /** - * Exiting the page. Subclasses may extend. - */ - protected void exit() { - } - - protected boolean getStatus(Integer key) { - return status.hasError(key); - } - - /** - * Sent when an event that the receiver has registered for occurs. If a subclass overrides this - * method, it must call super. - * - * @param event - * the event which occurred - */ - public void handleEvent(org.eclipse.swt.widgets.Event event) { - } - - /** - * Set the error message for this page based on the last error in the ValidationStatus. - */ - protected void setErrorMessage() { - String error = status.getLastErrMsg(); - if (error == null) { - if (getErrorMessage() != null) - setErrorMessage((String) null); - String warning = status.getLastWarningMsg(); - if (warning == null) { - if (getMessage() != null && getMessageType() == IMessageProvider.WARNING) - setMessage(null, IMessageProvider.WARNING); - else { - String info = status.getLastInfoMsg(); - if (info == null) { - if (getMessage() != null && getMessageType() == IMessageProvider.INFORMATION) - setMessage(null, IMessageProvider.INFORMATION); - } else if (!info.equals(getMessage())) { - setMessage(info, IMessageProvider.INFORMATION); - } - } - } else if (!warning.equals(getMessage())) - setMessage(warning, IMessageProvider.WARNING); - } else if (!error.equals(getErrorMessage())) - setErrorMessage(error); - } - - protected void setErrorStatus(Integer key, String errorMessage) { - status.setErrorStatus(key, errorMessage); - } - - protected void setWarningStatus(Integer key, String warningMessage) { - status.setWarningStatus(key, warningMessage); - } - - protected void setInfoStatus(Integer key, String infoMessage) { - status.setInfoStatus(key, infoMessage); - } - - protected void setOKStatus(Integer key) { - status.setOKStatus(key); - } - - /** - * This should be called by the Wizard just prior to running the performFinish operation. - * Subclasses should override to store their default settings. - */ - public void storeDefaultSettings() { - } - - /** - * The page is now being validated. At this time, each control is validated and then the - * controls are updated based on the results in the ValidationStatus which was updated during - * <code>validateControls()</code>. Finally, it will display the last error message and it - * will set the page complete. Subclasses will not typically override this method. - */ - protected void validatePage() { - if (!isValidating) { - isValidating = true; - try { - validateControlsBase(); - updateControls(); - setErrorMessage(); - setValid(status.getLastErrMsg() == null); - } - finally { - isValidating = false; - } - } - } - - /** - * Validate individual controls. Use validation keys to keep track of errors. - * - * @see setOKStatus(Integer) and setErrorMessage(Integer, String) - */ - protected final String validateControlsBase() { - if (!validationMap.isEmpty()) { - String propName; - for (int i = 0; i < validationPropertyNames.length; i++) { - propName = validationPropertyNames[i]; - Integer valKey = (Integer) validationMap.get(propName); - if (valKey != null) - validateProperty(propName, valKey); - if (!getStatus(valKey)) - return propName; - } - } - return null; - } - - /** - * @param propertyName - * @param validationkey - */ - private void validateProperty(String propertyName, Integer validationKey) { - setOKStatus(validationKey); - IStatus status1 = model.validateProperty(propertyName); - if (!status1.isOK()) { - String message = status1.isMultiStatus() ? status1.getChildren()[0].getMessage() : status1.getMessage(); - switch (status1.getSeverity()) { - case IStatus.ERROR : - setErrorStatus(validationKey, message); - break; - case IStatus.WARNING : - setWarningStatus(validationKey, message); - break; - case IStatus.INFO : - setInfoStatus(validationKey, message); - break; - } - } - } - - /** - * Update the enablement of controls after validation. Sublcasses should check the status of - * validation keys to determine enablement. - */ - protected void updateControls() { - } - - - /* - * If a property changes that we want to validate, force validation on this page. - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModelListener#propertyChanged(java.lang.String, - * java.lang.Object, java.lang.Object) - */ - public void propertyChanged(DataModelEvent event) { - String propertyName = event.getPropertyName(); - if (validationPropertyNames != null && (event.getFlag() == DataModelEvent.VALUE_CHG || (!isValid() && event.getFlag() == DataModelEvent.VALID_VALUES_CHG))) { - for (int i = 0; i < validationPropertyNames.length; i++) { - if (validationPropertyNames[i].equals(propertyName)) { - validatePage(); - break; - } - } - } - } - - /** - * @return Returns the model. - */ - protected IDataModel getDataModel() { - return model; - } - - public void dispose() { - super.dispose(); - if (synchHelper != null) { - synchHelper.dispose(); - synchHelper = null; - } - } - - protected String getInfopopID() { - return infopopID; - } - - public void setInfopopID(String infopopID) { - this.infopopID = infopopID; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java deleted file mode 100644 index 84a6c706e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java +++ /dev/null @@ -1,1617 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.properties; - -import static org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi.createInstallLibraryPanel; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.ElementChangedEvent; -import org.eclipse.jdt.core.IElementChangedListener; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaElementDelta; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper; -import org.eclipse.jpt.common.ui.internal.properties.JptProjectPropertiesPage; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.utility.internal.BitTools; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.NotBooleanTransformer; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.common.utility.internal.model.value.AbstractCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.AspectCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.BufferedWritablePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CompositePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ExtendedListValueModelWrapper; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter; -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.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.TransformationWritablePropertyValueModel; -import org.eclipse.jpt.common.utility.model.Model; -import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent; -import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent; -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.listener.PropertyChangeListener; -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.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaDataSource; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JpaProjectManager; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.internal.JptCoreMessages; -import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0; -import org.eclipse.jpt.jpa.core.libprov.JpaLibraryProviderInstallOperationConfig; -import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription; -import org.eclipse.jpt.jpa.db.Catalog; -import org.eclipse.jpt.jpa.db.ConnectionAdapter; -import org.eclipse.jpt.jpa.db.ConnectionListener; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.ConnectionProfileFactory; -import org.eclipse.jpt.jpa.db.ConnectionProfileListener; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.JptJpaDbPlugin; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.db.ui.internal.DTPUiTools; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.jpa2.Jpa2_0ProjectFlagModel; -import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import com.ibm.icu.text.Collator; - -/** - * Way more complicated UI than you would think.... - */ -public class JpaProjectPropertiesPage - extends JptProjectPropertiesPage { - - public static final String PROP_ID = "org.eclipse.jpt.jpa.ui.jpaProjectProperties"; //$NON-NLS-1$ - - private PropertyValueModel<JpaProject> jpaProjectModel; - - private BufferedWritablePropertyValueModel<String> platformIdModel; - private PropertyChangeListener platformIdListener; - - private BufferedWritablePropertyValueModel<String> connectionModel; - private PropertyValueModel<ConnectionProfile> connectionProfileModel; - private PropertyValueModel<Boolean> disconnectedModel; - private PropertyChangeListener disconnectedModelListener; - private Link connectLink; - - private BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultCatalogFlagModel; - private BufferedWritablePropertyValueModel<String> userOverrideDefaultCatalogModel; - private WritablePropertyValueModel<String> defaultCatalogModel; - private ListValueModel<String> catalogChoicesModel; - - private BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultSchemaFlagModel; - private BufferedWritablePropertyValueModel<String> userOverrideDefaultSchemaModel; - private WritablePropertyValueModel<String> defaultSchemaModel; - private ListValueModel<String> schemaChoicesModel; - - private BufferedWritablePropertyValueModel<Boolean> discoverAnnotatedClassesModel; - private WritablePropertyValueModel<Boolean> listAnnotatedClassesModel; - - private PropertyValueModel<Boolean> jpa2_0ProjectFlagModel; - - private BufferedWritablePropertyValueModel<String> metamodelSourceFolderModel; - private ListValueModel<String> javaSourceFolderChoicesModel; - - private static final String BUILD_PATHS_PROPERTY_PAGE_ID = "org.eclipse.jdt.ui.propertyPages.BuildPathsPropertyPage"; //$NON-NLS-1$ - - - @SuppressWarnings("unchecked") - /* private */ static final Comparator<String> STRING_COMPARATOR = Collator.getInstance(); - - - // ************ construction ************ - - public JpaProjectPropertiesPage() { - super(); - } - - @Override - protected void buildModels() { - this.jpaProjectModel = new JpaProjectModel(this.projectModel); - - this.platformIdModel = this.buildPlatformIdModel(); - this.platformIdListener = this.buildPlatformIdListener(); - - this.connectionModel = this.buildConnectionModel(); - this.connectionProfileModel = this.buildConnectionProfileModel(); - this.disconnectedModel = this.buildDisconnectedModel(); - this.disconnectedModelListener = buildDisconnectedModelListener(); - - this.userOverrideDefaultCatalogFlagModel = this.buildUserOverrideDefaultCatalogFlagModel(); - this.userOverrideDefaultCatalogModel = this.buildUserOverrideDefaultCatalogModel(); - this.defaultCatalogModel = this.buildDefaultCatalogModel(); - this.catalogChoicesModel = this.buildCatalogChoicesModel(); - - this.userOverrideDefaultSchemaFlagModel = this.buildUserOverrideDefaultSchemaFlagModel(); - this.userOverrideDefaultSchemaModel = this.buildUserOverrideDefaultSchemaModel(); - this.defaultSchemaModel = this.buildDefaultSchemaModel(); - this.schemaChoicesModel = this.buildSchemaChoicesModel(); - - this.discoverAnnotatedClassesModel = this.buildDiscoverAnnotatedClassesModel(); - this.listAnnotatedClassesModel = this.buildListAnnotatedClassesModel(); - - this.jpa2_0ProjectFlagModel = this.buildJpa2_0ProjectFlagModel(); - - this.metamodelSourceFolderModel = this.buildMetamodelSourceFolderModel(); - this.javaSourceFolderChoicesModel = this.buildJavaSourceFolderChoicesModel(); - } - - // ***** platform ID model - private BufferedWritablePropertyValueModel<String> buildPlatformIdModel() { - return new BufferedWritablePropertyValueModel<String>(new PlatformIdModel(this.jpaProjectModel), this.trigger); - } - - private PropertyChangeListener buildPlatformIdListener(){ - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - JpaProjectPropertiesPage.this.platformIdChanged((String) event.getNewValue()); - } - }; - } - - void platformIdChanged(String newPlatformId) { - if ( ! this.getControl().isDisposed()) { - // handle null, in the case the jpa facet is changed via the facets page, - // the library install delegate is temporarily null - adjustLibraryProviders(); - } - } - - // ***** connection models - private BufferedWritablePropertyValueModel<String> buildConnectionModel() { - return new BufferedWritablePropertyValueModel<String>(new ConnectionModel(this.jpaProjectModel), this.trigger); - } - - private PropertyValueModel<ConnectionProfile> buildConnectionProfileModel() { - return new ConnectionProfileModel(this.connectionModel); - } - - private PropertyValueModel<Boolean> buildDisconnectedModel() { - return new DisconnectedModel(this.connectionProfileModel); - } - - // ***** catalog models - private BufferedWritablePropertyValueModel<Boolean> buildUserOverrideDefaultCatalogFlagModel() { - return new BufferedWritablePropertyValueModel<Boolean>(new UserOverrideDefaultCatalogFlagModel(this.jpaProjectModel), this.trigger); - } - - private BufferedWritablePropertyValueModel<String> buildUserOverrideDefaultCatalogModel() { - return new BufferedWritablePropertyValueModel<String>(new UserOverrideDefaultCatalogModel(this.jpaProjectModel), this.trigger); - } - - private WritablePropertyValueModel<String> buildDefaultCatalogModel() { - return new DefaultModel( - this.userOverrideDefaultCatalogFlagModel, - this.userOverrideDefaultCatalogModel, - this.buildDatabaseDefaultCatalogModel() - ); - } - - private PropertyValueModel<String> buildDatabaseDefaultCatalogModel() { - return new DatabaseDefaultCatalogModel(this.connectionProfileModel); - } - - /** - * Add the default catalog if it is not on the list from the database - */ - private ListValueModel<String> buildCatalogChoicesModel() { - return new SortedListValueModelAdapter<String>(this.buildUnsortedCatalogChoicesModel(), STRING_COMPARATOR); - } - - /** - * Add the default catalog if it is not on the list from the database - */ - @SuppressWarnings("unchecked") - private CollectionValueModel<String> buildUnsortedCatalogChoicesModel() { - return new SetCollectionValueModel<String>( - new CompositeCollectionValueModel<CollectionValueModel<String>, String>( - new PropertyCollectionValueModelAdapter<String>(this.defaultCatalogModel), - this.buildDatabaseCatalogChoicesModel() - ) - ); - } - - private CollectionValueModel<String> buildDatabaseCatalogChoicesModel() { - return new DatabaseCatalogChoicesModel(this.connectionProfileModel); - } - - // ***** schema models - private BufferedWritablePropertyValueModel<Boolean> buildUserOverrideDefaultSchemaFlagModel() { - return new BufferedWritablePropertyValueModel<Boolean>(new UserOverrideDefaultSchemaFlagModel(this.jpaProjectModel), this.trigger); - } - - private BufferedWritablePropertyValueModel<String> buildUserOverrideDefaultSchemaModel() { - return new BufferedWritablePropertyValueModel<String>(new UserOverrideDefaultSchemaModel(this.jpaProjectModel), this.trigger); - } - - private WritablePropertyValueModel<String> buildDefaultSchemaModel() { - return new DefaultModel( - this.userOverrideDefaultSchemaFlagModel, - this.userOverrideDefaultSchemaModel, - this.buildDatabaseDefaultSchemaModel() - ); - } - - private PropertyValueModel<String> buildDatabaseDefaultSchemaModel() { - return new DatabaseDefaultSchemaModel(this.connectionProfileModel, this.defaultCatalogModel); - } - - /** - * Add the default catalog if it is not on the list from the database - */ - private ListValueModel<String> buildSchemaChoicesModel() { - return new SortedListValueModelAdapter<String>(this.buildUnsortedSchemaChoicesModel(), STRING_COMPARATOR); - } - - @SuppressWarnings("unchecked") - private CollectionValueModel<String> buildUnsortedSchemaChoicesModel() { - return new SetCollectionValueModel<String>( - new CompositeCollectionValueModel<CollectionValueModel<String>, String>( - new PropertyCollectionValueModelAdapter<String>(this.defaultSchemaModel), - this.buildDatabaseSchemaChoicesModel() - ) - ); - } - - private CollectionValueModel<String> buildDatabaseSchemaChoicesModel() { - return new DatabaseSchemaChoicesModel(this.connectionProfileModel, this.defaultCatalogModel); - } - - // ***** discover/list annotated classes models - private BufferedWritablePropertyValueModel<Boolean> buildDiscoverAnnotatedClassesModel() { - return new BufferedWritablePropertyValueModel<Boolean>(new DiscoverAnnotatedClassesModel(this.jpaProjectModel), this.trigger); - } - - /** - * The opposite of the "discover annotated classes" flag. - */ - private WritablePropertyValueModel<Boolean> buildListAnnotatedClassesModel() { - return new TransformationWritablePropertyValueModel<Boolean, Boolean>(this.discoverAnnotatedClassesModel, NotBooleanTransformer.instance()); - } - - // ***** JPA 2.0 project flag - private PropertyValueModel<Boolean> buildJpa2_0ProjectFlagModel() { - return new Jpa2_0ProjectFlagModel<JpaProject>(this.jpaProjectModel); - } - - // ***** metamodel models - private BufferedWritablePropertyValueModel<String> buildMetamodelSourceFolderModel() { - return new BufferedWritablePropertyValueModel<String>(new MetamodelSourceFolderModel(this.jpaProjectModel), this.trigger); - } - - private ListValueModel<String> buildJavaSourceFolderChoicesModel() { - // by default, ExtendedListValueModelWrapper puts a null at the top of the list - return new ExtendedListValueModelWrapper<String>( - new SortedListValueModelAdapter<String>( - new JavaSourceFolderChoicesModel(this.jpaProjectModel), - STRING_COMPARATOR - ) - ); - } - - - // ********** convenience methods ********** - - private String getConnectionName() { - return this.connectionModel.getValue(); - } - - private ConnectionProfile getConnectionProfile() { - return this.connectionProfileModel.getValue(); - } - - private boolean userOverrideDefaultCatalogFlagIsSet() { - return flagIsSet(this.userOverrideDefaultCatalogFlagModel); - } - - private String getUserOverrideDefaultCatalog() { - return this.userOverrideDefaultCatalogModel.getValue(); - } - - private boolean userOverrideDefaultSchemaFlagIsSet() { - return flagIsSet(this.userOverrideDefaultSchemaFlagModel); - } - - private String getUserOverrideDefaultSchema() { - return this.userOverrideDefaultSchemaModel.getValue(); - } - - private IWorkbenchPreferenceContainer getWorkbenchPreferenceContainer() { - IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); - return container; - } - - // ********** LibraryFacetPropertyPage implementation ********** - - @Override - public IProjectFacetVersion getProjectFacetVersion() { - return this.getFacetedProject().getInstalledVersion(JpaFacet.FACET); - } - - @Override - protected void adjustLibraryProviders() { - LibraryInstallDelegate lid = this.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.setJpaPlatform(JptJpaCorePlugin.getJpaPlatformManager().getJpaPlatform(this.platformIdModel.getValue())); - } - } - } - - - // ********** page ********** - - @Override - protected void createWidgets(Composite parent) { - this.buildPlatformGroup(parent); - - Control libraryProviderComposite = createInstallLibraryPanel( - parent, - this.getLibraryInstallDelegate(), - JptUiMessages.JpaFacetWizardPage_jpaImplementationLabel); - - libraryProviderComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - this.buildConnectionGroup(parent); - this.buildPersistentClassManagementGroup(parent); - this.buildMetamodelGroup(parent); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE); - } - - @Override - protected void engageListeners() { - super.engageListeners(); - this.platformIdModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener); - this.disconnectedModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener); - } - - @Override - protected void disengageListeners() { - this.platformIdModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener); - this.disconnectedModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener); - super.disengageListeners(); - } - - - // ********** platform group ********** - - private void buildPlatformGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptUiMessages.JpaFacetWizardPage_platformLabel); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Combo platformDropDown = buildDropDown(group); - SWTTools.bind( - buildPlatformChoicesModel(), - this.platformIdModel, - platformDropDown, - JPA_PLATFORM_LABEL_CONVERTER); - - buildFacetsPageLink(group, JptUiMessages.JpaFacetWizardPage_facetsPageLink); - } - - /** - * Add the project's JPA platform if it is not on the list of valid - * platforms. - * <p> - * This is probably only useful if the project is corrupted - * and has a platform that exists in the registry but is not on the - * list of valid platforms for the project's JPA facet version. - * Because, if the project's JPA platform is completely invalid, there - * would be no JPA project! - */ - @SuppressWarnings("unchecked") - private ListValueModel<String> buildPlatformChoicesModel() { - return new SortedListValueModelAdapter<String>( - new SetCollectionValueModel<String>( - new CompositeCollectionValueModel<CollectionValueModel<String>, String>( - new PropertyCollectionValueModelAdapter<String>(this.platformIdModel), - this.buildRegistryPlatformsModel() - ) - ), - JPA_PLATFORM_COMPARATOR - ); - } - - private CollectionValueModel<String> buildRegistryPlatformsModel() { - Iterable<String> enabledPlatformIds = - new TransformationIterable<JpaPlatformDescription, String>( - new FilteringIterable<JpaPlatformDescription>(JptJpaCorePlugin.getJpaPlatformManager().getJpaPlatforms()) { - @Override - protected boolean accept(JpaPlatformDescription o) { - return o.supportsJpaFacetVersion(getProjectFacetVersion()); - } - }) { - @Override - protected String transform(JpaPlatformDescription o) { - return o.getId(); - } - }; - return new StaticCollectionValueModel<String>(enabledPlatformIds); - } - - private static final Comparator<String> JPA_PLATFORM_COMPARATOR = - new Comparator<String>() { - public int compare(String id1, String id2) { - String label1 = getJpaPlatformLabel(id1); - String label2 = getJpaPlatformLabel(id2); - return STRING_COMPARATOR.compare(label1, label2); - } - }; - - private static final StringConverter<String> JPA_PLATFORM_LABEL_CONVERTER = - new StringConverter<String>() { - public String convertToString(String id) { - return getJpaPlatformLabel(id); - } - }; - - /* private */ static String getJpaPlatformLabel(String id) { - return JptJpaCorePlugin.getJpaPlatformManager().getJpaPlatform(id).getLabel(); - } - - - // ********** connection group ********** - - private void buildConnectionGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptUiMessages.JpaFacetWizardPage_connectionLabel); - group.setLayout(new GridLayout(3, false)); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE_CONNECTION); - - Combo connectionDropDown = this.buildDropDown(group, 3); - SWTTools.bind( - CONNECTION_CHOICES_MODEL, - this.connectionModel, - connectionDropDown, - SIMPLE_STRING_CONVERTER - ); - - Link addConnectionLink = this.buildLink(group, JptUiMessages.JpaFacetWizardPage_connectionLink); - addConnectionLink.addSelectionListener(this.buildAddConnectionLinkListener()); // the link will be GCed - - this.connectLink = this.buildLink(group, buildConnectLinkText()); - SWTTools.controlEnabledState(this.disconnectedModel, this.connectLink); - this.connectLink.addSelectionListener(this.buildConnectLinkListener()); // the link will be GCed - - // override default catalog - Button overrideDefaultCatalogCheckBox = this.buildCheckBox(group, 3, JptUiMessages.JpaFacetWizardPage_overrideDefaultCatalogLabel); - SWTTools.bind(this.userOverrideDefaultCatalogFlagModel, overrideDefaultCatalogCheckBox); - - Label defaultCatalogLabel = this.buildLabel(group, JptUiMessages.JpaFacetWizardPage_defaultCatalogLabel); - Combo defaultCatalogDropDown = this.buildDropDown(group); - SWTTools.bind(this.catalogChoicesModel, this.defaultCatalogModel, defaultCatalogDropDown); - - SWTTools.controlEnabledState(this.userOverrideDefaultCatalogFlagModel, defaultCatalogLabel, defaultCatalogDropDown); - - // override default schema - Button overrideDefaultSchemaButton = this.buildCheckBox(group, 3, JptUiMessages.JpaFacetWizardPage_overrideDefaultSchemaLabel); - SWTTools.bind(this.userOverrideDefaultSchemaFlagModel, overrideDefaultSchemaButton); - - Label defaultSchemaLabel = this.buildLabel(group, JptUiMessages.JpaFacetWizardPage_defaultSchemaLabel); - Combo defaultSchemaDropDown = this.buildDropDown(group); - SWTTools.bind(this.schemaChoicesModel, this.defaultSchemaModel, defaultSchemaDropDown); - - SWTTools.controlEnabledState(this.userOverrideDefaultSchemaFlagModel, defaultSchemaLabel, defaultSchemaDropDown); - } - - private static final StringConverter<String> SIMPLE_STRING_CONVERTER = - new StringConverter<String>() { - public String convertToString(String string) { - return (string != null) ? string : JptUiMessages.JpaFacetWizardPage_none; - } - }; - - private PropertyChangeListener buildDisconnectedModelListener() { - return new SWTPropertyChangeListenerWrapper(buildDisconnectedModelListener_()); - } - - private PropertyChangeListener buildDisconnectedModelListener_() { - return new PropertyChangeListener() { - - public void propertyChanged(PropertyChangeEvent event) { - JpaProjectPropertiesPage.this.updateConnectLinkText(buildConnectLinkText()); - } - }; - } - - private String buildConnectLinkText(){ - ConnectionProfile connectionProfile = getConnectionProfile(); - if (connectionProfile != null && connectionProfile.isConnected()) { - return JptUiMessages.JpaFacetWizardPage_connectedText; - } - else { - return JptUiMessages.JpaFacetWizardPage_connectLink; - } - } - - private void updateConnectLinkText(String text) { - connectLink.setText(text); - SWTUtil.reflow(connectLink.getParent()); - } - - private SelectionListener buildAddConnectionLinkListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - JpaProjectPropertiesPage.this.openNewConnectionWizard(); - } - @Override - public String toString() { - return "connection link listener"; //$NON-NLS-1$ - } - }; - } - - void openNewConnectionWizard() { - String connectionName = DTPUiTools.createNewConnectionProfile(); - if (connectionName != null) { - this.connectionModel.setValue(connectionName); - } - } - - private SelectionListener buildConnectLinkListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - JpaProjectPropertiesPage.this.openConnectionProfile(); - } - @Override - public String toString() { - return "connect link listener"; //$NON-NLS-1$ - } - }; - } - - void openConnectionProfile() { - ConnectionProfile cp = this.getConnectionProfile(); - if (cp != null) { - cp.connect(); - } - } - - - // ********** persistent class management group ********** - - private void buildPersistentClassManagementGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptUiMessages.JpaFacetWizardPage_persistentClassManagementLabel); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Button discoverClassesRadioButton = this.buildRadioButton(group, 1, JptUiMessages.JpaFacetWizardPage_discoverClassesButton); - SWTTools.bind(this.discoverAnnotatedClassesModel, discoverClassesRadioButton); - - Button listClassesRadioButton = this.buildRadioButton(group, 1, JptUiMessages.JpaFacetWizardPage_listClassesButton); - SWTTools.bind(this.listAnnotatedClassesModel, listClassesRadioButton); - } - - - // ********** metamodel group ********** - - private void buildMetamodelGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptUiMessages.JpaFacetWizardPage_metamodelLabel); - group.setLayout(new GridLayout(3, false)); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Link metamodelSourceFolderLink = this.buildLink(group, JptUiMessages.JpaFacetWizardPage_metamodelSourceFolderLink); - metamodelSourceFolderLink.addSelectionListener(buildMetamodelSourceFolderLinkListener()); - Combo metamodelSourceFolderDropDown = this.buildDropDown(group); - SWTTools.bind( - this.javaSourceFolderChoicesModel, - this.metamodelSourceFolderModel, - metamodelSourceFolderDropDown, - SIMPLE_STRING_CONVERTER - ); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE_METAMODEL); - - SWTTools.controlVisibleState(this.jpa2_0ProjectFlagModel, group, metamodelSourceFolderLink, metamodelSourceFolderDropDown); - } - - private SelectionListener buildMetamodelSourceFolderLinkListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - JpaProjectPropertiesPage.this.openJavaBuildPathPage(); - } - @Override - public String toString() { - return "metamodel source folder link listener"; //$NON-NLS-1$ - } - }; - } - - void openJavaBuildPathPage() { - IWorkbenchPreferenceContainer container = getWorkbenchPreferenceContainer(); - container.openPage(BUILD_PATHS_PROPERTY_PAGE_ID, null); - } - - // ********** OK/Revert/Apply behavior ********** - - @Override - protected boolean projectRebuildRequired() { - return this.platformIdModel.isBuffering(); - } - - @Override - protected void rebuildProject() { - // if the JPA platform is changed, we need to completely rebuild the JPA project - JptJpaCorePlugin.rebuildJpaProject(this.getProject()); - } - - @Override - protected BufferedWritablePropertyValueModel<?>[] buildBufferedModels() { - return new BufferedWritablePropertyValueModel[] { - this.platformIdModel, - this.connectionModel, - this.userOverrideDefaultCatalogFlagModel, - this.userOverrideDefaultCatalogModel, - this.userOverrideDefaultSchemaFlagModel, - this.userOverrideDefaultSchemaModel, - this.discoverAnnotatedClassesModel, - this.metamodelSourceFolderModel - }; - } - - - // ********** validation ********** - - @Override - protected Model[] buildValidationModels() { - return new Model[] { - this.platformIdModel, - this.connectionModel, - this.userOverrideDefaultCatalogFlagModel, - this.defaultCatalogModel, - this.userOverrideDefaultSchemaFlagModel, - this.defaultSchemaModel, - this.discoverAnnotatedClassesModel - }; - } - - @Override - protected void performValidation(Map<Integer, ArrayList<IStatus>> statuses) { - /* platform */ - // user is unable to unset the platform, so no validation necessary - - /* library provider */ - super.performValidation(statuses); - - /* connection */ - ConnectionProfile connectionProfile = this.getConnectionProfile(); - String connectionName = this.getConnectionName(); - if ( ! StringTools.stringIsEmpty(connectionName)) { - if (connectionProfile == null) { - statuses.get(ERROR_STATUS).add(this.buildErrorStatus(NLS.bind( - JptCoreMessages.VALIDATE_CONNECTION_INVALID, - connectionName))); - } - else if ( ! connectionProfile.isActive()) { - statuses.get(INFO_STATUS).add(this.buildInfoStatus(JptCoreMessages.VALIDATE_CONNECTION_NOT_CONNECTED)); - } - } - - /* default catalog */ - if (this.userOverrideDefaultCatalogFlagIsSet()) { - String defaultCatalog = this.getUserOverrideDefaultCatalog(); - if (StringTools.stringIsEmpty(defaultCatalog)) { - statuses.get(ERROR_STATUS).add(this.buildErrorStatus(JptCoreMessages.VALIDATE_DEFAULT_CATALOG_NOT_SPECIFIED)); - } - else if ((connectionProfile != null) - && connectionProfile.isConnected() - && ! CollectionTools.contains(this.catalogChoicesModel.iterator(), defaultCatalog)) { - statuses.get(WARNING_STATUS).add(this.buildWarningStatus(NLS.bind( - JptCoreMessages.VALIDATE_CONNECTION_DOESNT_CONTAIN_CATALOG, - defaultCatalog - ))); - } - } - - /* default schema */ - if (this.userOverrideDefaultSchemaFlagIsSet()) { - String defaultSchema = this.getUserOverrideDefaultSchema(); - if (StringTools.stringIsEmpty(defaultSchema)) { - statuses.get(ERROR_STATUS).add(this.buildErrorStatus(JptCoreMessages.VALIDATE_DEFAULT_SCHEMA_NOT_SPECIFIED)); - } - else if ((connectionProfile != null) - && connectionProfile.isConnected() - && ! CollectionTools.contains(this.schemaChoicesModel.iterator(), defaultSchema)) { - statuses.get(WARNING_STATUS).add(this.buildWarningStatus(NLS.bind( - JptCoreMessages.VALIDATE_CONNECTION_DOESNT_CONTAIN_SCHEMA, - defaultSchema - ))); - } - } - } - - - // ********** UI model adapters ********** - - /** - * Treat the JPA project as an "aspect" of the Eclipse project (IProject); - * but the JPA project is stored in the JPA model, not the Eclipse project - * itself.... - * We also need to listen for the JPA project to be rebuilt if the user - * changes the Eclipse project's JPA platform (which is stored in the - * Eclipse project's preferences). - */ - static class JpaProjectModel - extends AspectPropertyValueModelAdapter<IProject, JpaProject> { - - /** - * The JPA 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 CollectionChangeListener projectManagerListener; - - - JpaProjectModel(PropertyValueModel<IProject> projectModel) { - super(projectModel); - 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) { - JpaProjectModel.this.platformChanged(); - } - }; - } - - void platformChanged() { - this.propertyChanged(); - } - - @Override - protected void engageSubject_() { - JptJpaCorePlugin.getJpaProjectManager().addCollectionChangeListener( - JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectManagerListener); - } - - @Override - protected void disengageSubject_() { - JptJpaCorePlugin.getJpaProjectManager().removeCollectionChangeListener( - JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectManagerListener); - } - - @Override - protected JpaProject buildValue_() { - return JptJpaCorePlugin.getJpaProject(this.subject); - } - } - - - /** - * The JPA project's data source is an auxiliary object that never changes; - * so if we have a JPA project, we have a JPA data source also. - */ - static class DataSourceModel - extends TransformationPropertyValueModel<JpaProject, JpaDataSource> - { - DataSourceModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel); - } - - @Override - protected JpaDataSource transform_(JpaProject value) { - return value.getDataSource(); - } - } - - - /** - * The DTP connection profile name is an aspect of the JPA project's - * data source - */ - static class ConnectionModel - extends PropertyAspectAdapter<JpaDataSource, String> - { - ConnectionModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(new DataSourceModel(jpaProjectModel), JpaDataSource.CONNECTION_PROFILE_NAME_PROPERTY); - } - - @Override - protected String buildValue_() { - return this.subject.getConnectionProfileName(); - } - - @Override - public void setValue_(String connection) { - this.subject.setConnectionProfileName(connection); - } - } - - - /** - * Convert the selected connection profile name to a connection profile - */ - static class ConnectionProfileModel - extends CachingTransformationPropertyValueModel<String, ConnectionProfile> - { - ConnectionProfileModel(PropertyValueModel<String> connectionModel) { - super(connectionModel); - } - - @Override - protected ConnectionProfile transform_(String connectionName) { - return JptJpaDbPlugin.getConnectionProfileFactory().buildConnectionProfile(connectionName); - } - } - - - /** - * Treat the JPA platform ID as an "aspect" of the JPA project. - * The platform ID is stored in the project preferences. - * The platform ID does not change for a JPA project - if the user wants a - * different platform, we build an entirely new JPA project. - */ - static class PlatformIdModel - extends AspectPropertyValueModelAdapter<JpaProject, String> - { - PlatformIdModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel); - } - - @Override - protected String buildValue_() { - return JptJpaCorePlugin.getJpaPlatformId(this.subject.getProject()); - } - - @Override - public void setValue_(String newPlatformId) { - JptJpaCorePlugin.setJpaPlatformId(this.subject.getProject(), newPlatformId); - } - - @Override - protected void engageSubject_() { - // the platform ID does not change - } - - @Override - protected void disengageSubject_() { - // the platform ID does not change - } - } - - - /** - * The connections are held by a singleton, so the model can be a singleton - * also. - */ - // by default, ExtendedListValueModelWrapper puts a null at the top of the list - private static final ListValueModel<String> CONNECTION_CHOICES_MODEL = - new ExtendedListValueModelWrapper<String>( - new SortedListValueModelAdapter<String>( - new ConnectionChoicesModel(), - STRING_COMPARATOR - ) - ); - - /** - * Wrap the connection profile names held by the connection profile - * factory singleton. - */ - static class ConnectionChoicesModel - extends AbstractCollectionValueModel - implements CollectionValueModel<String> - { - private final ConnectionProfileListener connectionProfileListener; - - ConnectionChoicesModel() { - super(); - this.connectionProfileListener = this.buildConnectionProfileListener(); - } - - private ConnectionProfileListener buildConnectionProfileListener() { - return new ConnectionProfileListener() { - public void connectionProfileAdded(String name) { - ConnectionChoicesModel.this.collectionChanged(); - } - public void connectionProfileRemoved(String name) { - ConnectionChoicesModel.this.collectionChanged(); - } - public void connectionProfileRenamed(String oldName, String newName) { - // Ignore this event for now. Connecting a profile actually - // throws a connection renamed event, which messes up the - // list selection. There shouldn't be a connection renamed - // within the scope of this dialog anyhow. - // ConnectionChoicesModel.this.collectionChanged(); - } - }; - } - - void collectionChanged() { - this.fireCollectionChanged(CollectionValueModel.VALUES, CollectionTools.collection(this.iterator())); - } - - public Iterator<String> iterator() { - return this.getConnectionProfileFactory().getConnectionProfileNames().iterator(); - } - - public int size() { - return CollectionTools.size(this.iterator()); - } - - @Override - protected void engageModel() { - this.getConnectionProfileFactory().addConnectionProfileListener(this.connectionProfileListener); - } - - @Override - protected void disengageModel() { - this.getConnectionProfileFactory().removeConnectionProfileListener(this.connectionProfileListener); - } - - private ConnectionProfileFactory getConnectionProfileFactory() { - return JptJpaDbPlugin.getConnectionProfileFactory(); - } - } - - - /** - * Adapt whether the JPA project has a user override specified - * (either catalog or schema); - */ - abstract static class UserOverrideDefaultFlagModel - extends PropertyAspectAdapter<JpaProject, Boolean> - { - UserOverrideDefaultFlagModel(PropertyValueModel<JpaProject> jpaProjectModel, String propertyName) { - super(jpaProjectModel, propertyName); - } - - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.specifiesUserOverrideDefault()); - } - - boolean specifiesUserOverrideDefault() { - return ! StringTools.stringIsEmpty(this.getUserOverrideDefault()); - } - - abstract String getUserOverrideDefault(); - - @Override - protected void setValue_(Boolean value) { - // ignore - } - } - - - /** - * Whether the JPA project has a user override default catalog specified. - */ - static class UserOverrideDefaultCatalogFlagModel - extends UserOverrideDefaultFlagModel - { - UserOverrideDefaultCatalogFlagModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel, JpaProject.USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY); - } - @Override - public String getUserOverrideDefault() { - return this.subject.getUserOverrideDefaultCatalog(); - } - } - - - /** - * Whether the JPA project has a user override default schema specified. - */ - static class UserOverrideDefaultSchemaFlagModel - extends UserOverrideDefaultFlagModel - { - UserOverrideDefaultSchemaFlagModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel, JpaProject.USER_OVERRIDE_DEFAULT_SCHEMA_PROPERTY); - } - @Override - public String getUserOverrideDefault() { - return this.subject.getUserOverrideDefaultSchema(); - } - } - - - /** - * The JPA project's user override default catalog - */ - static class UserOverrideDefaultCatalogModel - extends PropertyAspectAdapter<JpaProject, String> - { - UserOverrideDefaultCatalogModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel, JpaProject.USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY); - } - - @Override - protected String buildValue_() { - return this.subject.getUserOverrideDefaultCatalog(); - } - - @Override - public void setValue_(String catalog) { - this.subject.setUserOverrideDefaultCatalog(catalog); - } - } - - - /** - * The JPA project's user override default catalog - */ - static class UserOverrideDefaultSchemaModel - extends PropertyAspectAdapter<JpaProject, String> - { - UserOverrideDefaultSchemaModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel, JpaProject.USER_OVERRIDE_DEFAULT_SCHEMA_PROPERTY); - } - - @Override - protected String buildValue_() { - return this.subject.getUserOverrideDefaultSchema(); - } - - @Override - public void setValue_(String schema) { - this.subject.setUserOverrideDefaultSchema(schema); - } - } - - - /** - * Flag on the JPA project indicating whether it should discover annotated - * classes - */ - static class DiscoverAnnotatedClassesModel - extends PropertyAspectAdapter<JpaProject, Boolean> - { - DiscoverAnnotatedClassesModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel, JpaProject.DISCOVERS_ANNOTATED_CLASSES_PROPERTY); - } - - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.discoversAnnotatedClasses()); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setDiscoversAnnotatedClasses(value.booleanValue()); - } - } - - /** - * The folder where the source for the generated Canonical Metamodel - * is written. - */ - static class MetamodelSourceFolderModel - extends PropertyAspectAdapter<JpaProject, String> - { - MetamodelSourceFolderModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel, JpaProject2_0.METAMODEL_SOURCE_FOLDER_NAME_PROPERTY); - } - - @Override - protected String buildValue_() { - return jpaProjectIsJpa2_0() ? ((JpaProject2_0) this.subject).getMetamodelSourceFolderName() : null; - } - - @Override - protected void setValue_(String value) { - if (this.jpaProjectIsJpa2_0()) { - ((JpaProject2_0) this.subject).setMetamodelSourceFolderName(value); - } - } - - private boolean jpaProjectIsJpa2_0() { - return JptJpaCorePlugin.nodeIsJpa2_0Compatible(this.subject); - } - } - - - /** - * Java project source folders. - * We keep the metamodel source folder in synch with the Java source folders - * (i.e. if a Java source folder is deleted or removed from the build path, - * we remove the metamodel source folder); therefore the list of folder - * choices does not need to be augmented with the current folder (as we do - * when the current folder is not in the list of choices). - */ - static class JavaSourceFolderChoicesModel - extends AspectCollectionValueModelAdapter<JpaProject, String> - { - private final IElementChangedListener javaElementChangedListener; - - JavaSourceFolderChoicesModel(PropertyValueModel<JpaProject> jpaProjectModel) { - super(jpaProjectModel); - this.javaElementChangedListener = this.buildJavaElementChangedListener(); - } - - private IElementChangedListener buildJavaElementChangedListener() { - return new IElementChangedListener() { - public void elementChanged(ElementChangedEvent event) { - JavaSourceFolderChoicesModel.this.processJavaDelta(event.getDelta()); - } - }; - } - - void processJavaDelta(IJavaElementDelta delta) { - switch (delta.getElement().getElementType()) { - case IJavaElement.JAVA_MODEL : - this.processJavaDeltaChildren(delta); - break; - case IJavaElement.JAVA_PROJECT : - this.processJavaProjectDelta(delta); - break; - default : - break; // ignore everything else - } - } - - private void processJavaDeltaChildren(IJavaElementDelta delta) { - for (IJavaElementDelta child : delta.getAffectedChildren()) { - this.processJavaDelta(child); // recurse - } - } - - private void processJavaProjectDelta(IJavaElementDelta delta) { - IJavaProject javaProject = (IJavaProject) delta.getElement(); - if (javaProject.equals(this.subject.getJavaProject()) && this.classpathHasChanged(delta)) { - this.fireCollectionChanged(CollectionValueModel.VALUES, CollectionTools.collection(this.iterator())); - } - } - - private boolean classpathHasChanged(IJavaElementDelta delta) { - return this.deltaFlagIsSet(delta, IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED); - } - - private boolean deltaFlagIsSet(IJavaElementDelta delta, int flag) { - return (delta.getKind() == IJavaElementDelta.CHANGED) && - BitTools.flagIsSet(delta.getFlags(), flag); - } - - @Override - protected Iterable<String> getIterable() { - return this.jpaProjectIsJpa2_0() ? - ((JpaProject2_0) this.subject).getJavaSourceFolderNames() : - EmptyIterable.<String>instance(); - } - - private boolean jpaProjectIsJpa2_0() { - return JptJpaCorePlugin.nodeIsJpa2_0Compatible(this.subject); - } - - @Override - protected void engageSubject_() { - JavaCore.addElementChangedListener(this.javaElementChangedListener); - } - - @Override - protected void disengageSubject_() { - JavaCore.removeElementChangedListener(this.javaElementChangedListener); - } - } - - - /** - * Abstract property aspect adapter for DTP connection profile connection/database - */ - abstract static class ConnectionProfilePropertyAspectAdapter<V> - extends AspectPropertyValueModelAdapter<ConnectionProfile, V> - { - private final ConnectionListener connectionListener; - - ConnectionProfilePropertyAspectAdapter(PropertyValueModel<ConnectionProfile> connectionProfileModel) { - super(connectionProfileModel); - this.connectionListener = this.buildConnectionListener(); - } - - // the connection opening is probably the only thing that will happen... - private ConnectionListener buildConnectionListener() { - return new ConnectionAdapter() { - @Override - public void opened(ConnectionProfile profile) { - ConnectionProfilePropertyAspectAdapter.this.connectionOpened(profile); - } - }; - } - - void connectionOpened(ConnectionProfile profile) { - if (profile.equals(this.subject)) { - this.propertyChanged(); - } - } - - @Override - protected void engageSubject_() { - this.subject.addConnectionListener(this.connectionListener); - } - - @Override - protected void disengageSubject_() { - this.subject.removeConnectionListener(this.connectionListener); - } - } - - - /** - * Monitor the connection profile's connection to the database - * (used to enable the "Connect" link) - */ - static class DisconnectedModel - extends ConnectionProfilePropertyAspectAdapter<Boolean> - { - DisconnectedModel(PropertyValueModel<ConnectionProfile> connectionProfileModel) { - super(connectionProfileModel); - } - - @Override - protected Boolean buildValue_() { - return Boolean.valueOf((this.subject != null) && this.subject.isDisconnected()); - } - } - - - /** - * Database-determined default catalog - */ - static class DatabaseDefaultCatalogModel - extends ConnectionProfilePropertyAspectAdapter<String> - { - DatabaseDefaultCatalogModel(PropertyValueModel<ConnectionProfile> connectionProfileModel) { - super(connectionProfileModel); - } - - @Override - protected String buildValue_() { - Database db = this.subject.getDatabase(); - return (db == null) ? null : db.getDefaultCatalogIdentifier(); - } - } - - - /** - * The default schema is not derived purely from the database; it is also dependent - * on the current value of the default catalog (which may be overridden - * by the user). - */ - static class DatabaseDefaultSchemaModel - extends ConnectionProfilePropertyAspectAdapter<String> - { - private final PropertyValueModel<String> defaultCatalogModel; - private final PropertyChangeListener catalogListener; - - DatabaseDefaultSchemaModel( - PropertyValueModel<ConnectionProfile> connectionProfileModel, - PropertyValueModel<String> defaultCatalogModel - ) { - super(connectionProfileModel); - this.defaultCatalogModel = defaultCatalogModel; - this.catalogListener = this.buildCatalogListener(); - } - - private PropertyChangeListener buildCatalogListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - DatabaseDefaultSchemaModel.this.catalogChanged(); - } - }; - } - - void catalogChanged() { - this.propertyChanged(); - } - - @Override - protected void engageSubject_() { - super.engageSubject_(); - this.defaultCatalogModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.catalogListener); - } - - @Override - protected void disengageSubject_() { - this.defaultCatalogModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.catalogListener); - super.disengageSubject_(); - } - - @Override - protected String buildValue_() { - SchemaContainer sc = this.getSchemaContainer(); - return (sc == null) ? null : sc.getDefaultSchemaIdentifier(); - } - - private SchemaContainer getSchemaContainer() { - return this.databaseSupportsCatalogs() ? this.getCatalog() : this.getDatabase(); - } - - private boolean databaseSupportsCatalogs() { - Database db = this.getDatabase(); - return (db != null) && db.supportsCatalogs(); - } - - private Catalog getCatalog() { - String name = this.defaultCatalogModel.getValue(); - // if we get here we know the database is not null - return (name == null) ? null : this.getDatabase().getCatalogForIdentifier(name); - } - - private Database getDatabase() { - return this.subject.getDatabase(); - } - } - - - /** - * Abstract collection aspect adapter for DTP connection profile connection/database - */ - abstract static class ConnectionProfileCollectionAspectAdapter<E> - extends AspectCollectionValueModelAdapter<ConnectionProfile, E> - { - private final ConnectionListener connectionListener; - - ConnectionProfileCollectionAspectAdapter(PropertyValueModel<ConnectionProfile> connectionProfileModel) { - super(connectionProfileModel); - this.connectionListener = this.buildConnectionListener(); - } - - // the connection opening is probably the only thing that will happen... - private ConnectionListener buildConnectionListener() { - return new ConnectionAdapter() { - @Override - public void opened(ConnectionProfile profile) { - ConnectionProfileCollectionAspectAdapter.this.connectionOpened(profile); - } - }; - } - - void connectionOpened(ConnectionProfile profile) { - if (profile.equals(this.subject)) { - this.collectionChanged(); - } - } - - @Override - protected void engageSubject_() { - this.subject.addConnectionListener(this.connectionListener); - } - - @Override - protected void disengageSubject_() { - this.subject.removeConnectionListener(this.connectionListener); - } - } - - - /** - * Catalogs on the database. - */ - static class DatabaseCatalogChoicesModel - extends ConnectionProfileCollectionAspectAdapter<String> - { - DatabaseCatalogChoicesModel(PropertyValueModel<ConnectionProfile> connectionProfileModel) { - super(connectionProfileModel); - } - - @Override - protected Iterable<String> getIterable() { - Database db = this.subject.getDatabase(); - // use catalog *identifiers* since the string ends up being the "default" for various text entries - return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String>instance(); - } - } - - - /** - * Schemas on the database or catalog. - * This list is not derived purely from the database; it is also dependent - * on the current value of the default catalog (which may be overridden - * by the user). - */ - static class DatabaseSchemaChoicesModel - extends ConnectionProfileCollectionAspectAdapter<String> - { - private final PropertyValueModel<String> defaultCatalogModel; - private final PropertyChangeListener catalogListener; - - DatabaseSchemaChoicesModel( - PropertyValueModel<ConnectionProfile> connectionProfileModel, - PropertyValueModel<String> defaultCatalogModel - ) { - super(connectionProfileModel); - this.defaultCatalogModel = defaultCatalogModel; - this.catalogListener = this.buildCatalogListener(); - } - - private PropertyChangeListener buildCatalogListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - DatabaseSchemaChoicesModel.this.catalogChanged(); - } - }; - } - - void catalogChanged() { - this.collectionChanged(); - } - - @Override - protected void engageSubject_() { - super.engageSubject_(); - this.defaultCatalogModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.catalogListener); - } - - @Override - protected void disengageSubject_() { - this.defaultCatalogModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.catalogListener); - super.disengageSubject_(); - } - - @Override - protected Iterable<String> getIterable() { - SchemaContainer sc = this.getSchemaContainer(); - // use schema *identifiers* since the string ends up being the "default" for various text entries - return (sc != null) ? sc.getSortedSchemaIdentifiers() : EmptyIterable.<String>instance(); - } - - private SchemaContainer getSchemaContainer() { - return this.databaseSupportsCatalogs() ? this.getCatalog() : this.getDatabase(); - } - - private boolean databaseSupportsCatalogs() { - Database db = this.getDatabase(); - return (db != null) && db.supportsCatalogs(); - } - - private Catalog getCatalog() { - String name = this.defaultCatalogModel.getValue(); - // if we get here we know the database is not null - return (name == null) ? null : this.getDatabase().getCatalogForIdentifier(name); - } - - private Database getDatabase() { - return this.subject.getDatabase(); - } - } - - /** - * Combine various models to determine the default catalog or schema. - * If the user has checked the "Override Default" check-box, the default - * is the JPA project's user override default, otherwise the default is - * determined by the database. - */ - static class DefaultModel - extends CompositePropertyValueModel<String> - implements WritablePropertyValueModel<String> - { - private final PropertyValueModel<Boolean> userOverrideDefaultFlagModel; - private final WritablePropertyValueModel<String> userOverrideDefaultModel; - private final PropertyValueModel<String> databaseDefaultModel; - - DefaultModel( - PropertyValueModel<Boolean> userOverrideDefaultFlagModel, - WritablePropertyValueModel<String> userOverrideDefaultModel, - PropertyValueModel<String> databaseDefaultModel - ) { - super(userOverrideDefaultFlagModel, userOverrideDefaultModel, databaseDefaultModel); - this.userOverrideDefaultFlagModel = userOverrideDefaultFlagModel; - this.userOverrideDefaultModel = userOverrideDefaultModel; - this.databaseDefaultModel = databaseDefaultModel; - } - - /** - * If the checkbox has been unchecked, we need to clear out the JPA - * project's user override. - */ - @Override - protected void propertyChanged(PropertyChangeEvent event) { - super.propertyChanged(event); - if (event.getSource() == this.userOverrideDefaultFlagModel) { - if ( ! this.userOverrideDefaultFlagIsSet()) { - this.userOverrideDefaultModel.setValue(null); - } - } - } - - /** - * If the checkbox is checked, return the user override from the JPA project; - * otherwise return the default from the database - */ - @Override - protected String buildValue() { - return this.userOverrideDefaultFlagIsSet() ? - this.userOverrideDefaultModel.getValue() : - this.databaseDefaultModel.getValue(); - } - - /** - * This will be called when the user makes a selection from the - * drop-down; which is only possible when the checkbox is checked - * (and the drop-down is enabled). - */ - public void setValue(String value) { - this.userOverrideDefaultModel.setValue(value); - this.propertyChanged(); - } - - private boolean userOverrideDefaultFlagIsSet() { - return flagIsSet(this.userOverrideDefaultFlagModel); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getValue()); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/DefaultJpaSelection.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/DefaultJpaSelection.java deleted file mode 100644 index 20b5e9c322..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/DefaultJpaSelection.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -import org.eclipse.jpt.jpa.core.JpaStructureNode; - -/** - * Straightforward implementation of the JpaSelection interface. - */ -public class DefaultJpaSelection - implements JpaSelection -{ - private final JpaStructureNode selectedNode; - - - public DefaultJpaSelection(JpaStructureNode selectedNode) { - super(); - if (selectedNode == null) { - throw new NullPointerException("A 'selectedNode' is required; otherwise use NULL_SELECTION."); - } - this.selectedNode = selectedNode; - } - - public JpaStructureNode getSelectedNode() { - return this.selectedNode; - } - - public boolean isEmpty() { - // by definition, this selection is never empty - // use IJpaSelection.NULL_SELECTION for empty selections - return false; - } - - @Override - public boolean equals(Object obj) { - if (! (obj instanceof JpaSelection)) { - return false; - } - JpaSelection other = (JpaSelection) obj; - return ( ! other.isEmpty()) && this.selectedNode.equals(other.getSelectedNode()); - } - - @Override - public int hashCode() { - return this.selectedNode.hashCode(); - } - - @Override - public String toString() { - return this.selectedNode.toString(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/DefaultJpaSelectionManager.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/DefaultJpaSelectionManager.java deleted file mode 100644 index 8538d64fa7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/DefaultJpaSelectionManager.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.selection; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IPageListener; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * A {@link JpaSelectionManager} stores the current {@link JpaSelection} and - * notifies <code>ISelectionListener</code>s when the selection changes. - */ -public class DefaultJpaSelectionManager - implements JpaSelectionManager -{ - /* The window for which this object manages selections */ - private IWorkbenchWindow window; - - /* The set of pages for which this object is managing selections */ - private Set<IWorkbenchPage> pages; - - /* The active editor part */ - private IEditorPart activeEditor; - - private JpaSelection currentSelection; - - /* The map of <code>IJpaSelectionParticipant</code>s (keyed by part) */ - private Map<IWorkbenchPart, JpaSelectionParticipant> selectionParticipants; - - private IPageListener pageListener; - - private IPartListener2 partListener; - - - public DefaultJpaSelectionManager() { - super(); - pages = Collections.synchronizedSet(new HashSet<IWorkbenchPage>()); - selectionParticipants = Collections.synchronizedMap(new HashMap<IWorkbenchPart, JpaSelectionParticipant>()); - pageListener = new PageListener(); - partListener = new PartListener(); - currentSelection = DefaultJpaSelection.NULL_SELECTION; - } - - void init(IWorkbenchWindow aWindow) { - window = aWindow; - aWindow.addPageListener(pageListener); - initPage(aWindow.getActivePage()); - } - - private void initPage(IWorkbenchPage page) { - if ((page != null) && (! pages.contains(page))) { - page.addPartListener(partListener); - pages.add(page); - activateEditor(page.getActiveEditor()); - } - } - - private void disposePage(IWorkbenchPage page) { - if ((page != null) && (pages.contains(page))) { - page.removePartListener(partListener); - pages.remove(page); - } - } - - private void activateEditor(IEditorPart editor) { - if (editor == activeEditor) { - return; - } - if (activeEditor != null) { - inactivateEditor(activeEditor); - } - initPart(editor); - activeEditor = editor; - selectEditor(activeEditor); - } - - private void inactivateEditor(IEditorPart editor) { - - } - - void initPart(IWorkbenchPart part) { - if (part != null) { - if (selectionParticipants.get(part) == null) { - JpaSelectionParticipant selectionParticipant = - (JpaSelectionParticipant) part.getAdapter(JpaSelectionParticipant.class); - if (selectionParticipant != null) { - selectionParticipants.put(part, selectionParticipant); - } - } - } - } - - private void selectEditor(IEditorPart editor) { - selectPart(editor); - } - - void selectPart(IWorkbenchPart part) { - JpaSelectionParticipant selectionParticipant = getSelectionParticipant(part); - if (selectionParticipant != null) { - select(selectionParticipant.getSelection(), selectionParticipant); - } - } - - void hidePart(IWorkbenchPart part) { - JpaSelectionParticipant selectionParticipant = getSelectionParticipant(part); - if ((selectionParticipant != null) && (selectionParticipant.disposeOnHide())) { - closePart(part); - } - } - - void closePart(IWorkbenchPart part) { - JpaSelectionParticipant selectionParticipant = getSelectionParticipant(part); - if (selectionParticipant != null) { - disposePart(part); - checkForNoEditors(); - } - } - - void disposePart(IWorkbenchPart part) { - if ((part != null) && (selectionParticipants.containsKey(part))) { - selectionParticipants.remove(part).dispose(); - } - } - - void checkForNoEditors() { - IWorkbenchPage activePage = window.getActivePage(); - if ((activePage == null) - || (activePage.getEditorReferences().length == 0)) { - select(DefaultJpaSelection.NULL_SELECTION, null); - } - } - - public void register(IWorkbenchPart part) { - initPart(part); - } - - public boolean isRegistered(IWorkbenchPart part) { - return selectionParticipants.get(part) != null; - } - - public void select(JpaSelection newSelection, JpaSelectionParticipant source) { - if (currentSelection.equals(newSelection)) { - return; - } - - currentSelection = newSelection; - Object nonNullSource = (source == null) ? this : source; - fireSelectionChange( - new JpaSelectionEvent(newSelection, JpaSelectionEvent.SELECTION, nonNullSource) - ); - } - - public void deselect(JpaSelection oldSelection, JpaSelectionParticipant source) { - if (currentSelection.equals(oldSelection)) { - currentSelection = DefaultJpaSelection.NULL_SELECTION; - Object nonNullSource = (source == null) ? this : source; - fireSelectionChange( - new JpaSelectionEvent(oldSelection, JpaSelectionEvent.DESELECTION, nonNullSource) - ); - } - } - - private void fireSelectionChange(JpaSelectionEvent event) { - for (JpaSelectionParticipant sp : selectionParticipants.values()) { - sp.selectionChanged(event); - } - } - - private JpaSelectionParticipant getSelectionParticipant(IWorkbenchPart part) { - return selectionParticipants.get(part); - } - - public JpaSelection getCurrentSelection() { - return currentSelection; - } - - public void dispose() { - window.removePageListener(pageListener); - selectionParticipants.clear(); - - for (Iterator<IWorkbenchPage> stream = new CloneIterator<IWorkbenchPage>(this.pages); stream.hasNext(); ) { - this.disposePage(stream.next()); - } - - for (Iterator<IWorkbenchPart> stream = new CloneIterator<IWorkbenchPart>(selectionParticipants.keySet()); stream.hasNext(); ) { - this.disposePart(stream.next()); - } - } - - - private class PageListener implements IPageListener - { - public void pageActivated(IWorkbenchPage page) { - // nop - } - - PageListener() { - super(); - } - - public void pageClosed(IWorkbenchPage page) { - DefaultJpaSelectionManager.this.disposePage(page); - } - - public void pageOpened(IWorkbenchPage page) { - DefaultJpaSelectionManager.this.initPage(page); - } - } - - - private class PartListener implements IPartListener2 - { - PartListener() { - super(); - } - - public void partActivated(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - if (part != null) { - DefaultJpaSelectionManager.this.initPart(part); - DefaultJpaSelectionManager.this.selectPart(part); - } - } - - public void partBroughtToTop(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - if (part != null) { - initPart(part); - } - } - - public void partClosed(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - if (part != null) { - DefaultJpaSelectionManager.this.closePart(part); - DefaultJpaSelectionManager.this.disposePart(part); - DefaultJpaSelectionManager.this.checkForNoEditors(); - } - } - - public void partDeactivated(IWorkbenchPartReference partRef) { - // nop - } - - public void partHidden(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - if (part != null) { - DefaultJpaSelectionManager.this.hidePart(part); - } - } - - public void partInputChanged(IWorkbenchPartReference partRef) { - // nop - } - - public void partOpened(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - if (part != null) { - initPart(part); - } - } - - public void partVisible(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - if (part != null) { - initPart(part); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaDetailsSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaDetailsSelectionParticipant.java deleted file mode 100644 index 7ac9003d2c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaDetailsSelectionParticipant.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -import org.eclipse.jpt.jpa.ui.internal.views.JpaDetailsView; - - -public class JpaDetailsSelectionParticipant - implements JpaSelectionParticipant -{ - private final JpaDetailsView detailsView; - - - public JpaDetailsSelectionParticipant(JpaDetailsView detailsView) { - super(); - this.detailsView = detailsView; - } - - public JpaSelection getSelection() { - return this.detailsView.getSelection(); - } - - public void selectionChanged(JpaSelectionEvent evt) { - this.detailsView.select(evt.getSelection()); - } - - public boolean disposeOnHide() { - return false; - } - - public void dispose() { - // NOP - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelection.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelection.java deleted file mode 100644 index 667ead1c58..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelection.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.jpa.ui.internal.selection; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jpt.jpa.core.JpaStructureNode; - -@SuppressWarnings("nls") -public interface JpaSelection extends ISelection -{ - static JpaSelection NULL_SELECTION = - new JpaSelection() { - public JpaStructureNode getSelectedNode() { - return null; - } - - public boolean isEmpty() { - return true; - } - - @Override - public String toString() { - return "NULL SELECTION"; - } - }; - - - JpaStructureNode getSelectedNode(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionEvent.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionEvent.java deleted file mode 100644 index 81e4aac5b9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -import java.util.EventObject; - -public class JpaSelectionEvent extends EventObject -{ - /** - * Serializable uid - * @since 0.5 - */ - private static final long serialVersionUID = 1L; - - - /** - * Indicates that the selection object is now selected - */ - public static int SELECTION = 1; - - /** - * Indicates that the selection object has now been deselected - */ - public static int DESELECTION = 2; - - - /** - * The selection object whose selection status has changed - */ - private JpaSelection selection; - - /** - * The type of the selection event, either a SELECTION or a DESELECTION - */ - private int type; - - - public JpaSelectionEvent(JpaSelection theSelection, int theType, Object source) { - super(source); - selection = theSelection; - type = theType; - } - - /** - * Return the selection object whose selection status has changed - */ - public JpaSelection getSelection() { - return selection; - } - - /** - * Return the type of selection event, either a SELECTION or a DESELECTION - */ - public int getType() { - return type; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionManager.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionManager.java deleted file mode 100644 index daa17b7801..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionManager.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -import org.eclipse.ui.IWorkbenchPart; - -public interface JpaSelectionManager -{ - /** - * Return the current selection. - * This will never be null, but it may be empty. - */ - public JpaSelection getCurrentSelection(); - - /** - * Not to be called lightly, this will affect the selection for all interested - * objects in a window. - * @param newSelection The new selection for the current window. - * @param source The selection participant (if any) that is causing the - * selection. May be null. - */ - public void select(JpaSelection newSelection, JpaSelectionParticipant source); - - /** - * Not to be called lightly, this will affect the selection for all interested - * objects in a window. - * @param oldSelection The oldSelection will be deselected, iff it matches - * the current selection. If so, the new selection will be an empty JpaSelection. - * @param source The selection participant (if any) that is causing the - * selection. May be null. - */ - public void deselect(JpaSelection oldSelection, JpaSelectionParticipant source); - - /** - * This may be used to register a part with the selection manager if the part - * is known to need access to the selection manager before it is ever activated - * or in the case it may be activated prior to the selection manager being - * created. - * - * It should not be necessary to deregister a part, as that happens when the - * part is closed. - */ - public void register(IWorkbenchPart part); - - /** - * Returns true if the part is currently registered to respond to selections - * from this selection manager - */ - public boolean isRegistered(IWorkbenchPart part); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionParticipant.java deleted file mode 100644 index 4145c013ac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaSelectionParticipant.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -public interface JpaSelectionParticipant -{ - /** - * Return the current selection of the participant - */ - JpaSelection getSelection(); - - /** - * The selection has changed in the central selection manager. - * Update this participant accordingly. - */ - void selectionChanged(JpaSelectionEvent evt); - - /** - * Return whether this selection participant should disconnect itself from - * its part when its part is hidden from view. - * <b>Typically</b> editor participants will return true and view participants will - * return false. - */ - boolean disposeOnHide(); - - /** - * This participant is no longer needed (most likely because its part has - * closed). Dispose of it. - */ - void dispose(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaStructureSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaStructureSelectionParticipant.java deleted file mode 100644 index aded24a836..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaStructureSelectionParticipant.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jpt.jpa.ui.internal.views.structure.JpaStructureView; - -public class JpaStructureSelectionParticipant - implements JpaSelectionParticipant -{ - final JpaStructureView structureView; - - - public JpaStructureSelectionParticipant(JpaSelectionManager selectionManager, JpaStructureView structureView) { - super(); - this.structureView = structureView; - structureView.addSelectionChangedListener(new StructureViewSelectionListener(selectionManager, structureView)); - } - - public JpaSelection getSelection() { - return this.structureView.getJpaSelection(); - } - - public void selectionChanged(JpaSelectionEvent evt) { - if (evt.getSource() != this) { - this.structureView.select(evt.getSelection()); - } - } - - public boolean disposeOnHide() { - return false; - } - - public void dispose() { - // NOP - } - - - // ********** listener ********** - - private class StructureViewSelectionListener - implements ISelectionChangedListener - { - private final JpaSelectionManager selectionManager; - - StructureViewSelectionListener(JpaSelectionManager selectionManager, JpaStructureView structureView) { - super(); - this.selectionManager = selectionManager; - } - - public void selectionChanged(SelectionChangedEvent event) { - if (structureView.getViewSite().getWorkbenchWindow().getPartService().getActivePart() == structureView) { - selectionManager.select(this.structureViewSelection(), JpaStructureSelectionParticipant.this); - } - } - - private JpaSelection structureViewSelection() { - return JpaStructureSelectionParticipant.this.structureView.getJpaSelection(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/SelectionManagerFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/SelectionManagerFactory.java deleted file mode 100644 index b9bc9b9140..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/SelectionManagerFactory.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.selection; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.ui.IWindowListener; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -public class SelectionManagerFactory -{ - private static volatile SelectionManagerFactory INSTANCE; - - private static Object MUTEX = new Object(); - - - /** - * Each <code>IWorkbenchWindow</code> has its own <code>JpaSelectionManager</code> - * to track the selection events in the <code>IWorkbenchWindow</code>. All - * <code>ISelectionListener</code>s in the same <code>IWorkbenchWindow</code> - * share the same <code>JpaSelectionManager</code>. - * - * @return The <code>JpaSelectionManager</code> associated with the current - * <code>IWorkbenchWindow</code> - */ - public static JpaSelectionManager getSelectionManager(IWorkbenchWindow window) { - if (INSTANCE == null) { - // this is thread safe for now. you never know whats comming - synchronized (MUTEX) { - if(INSTANCE == null) { - INSTANCE = new SelectionManagerFactory(); - // if we do the init inside the constructor we end up in a loop - // because the addWindowListener(this) does a callback to us - INSTANCE.init(); - } - } - } - return INSTANCE.internalGetSelectionManager(window); - } - - - Map<IWorkbenchWindow, DefaultJpaSelectionManager> managers; - - private WindowListener windowListener; - - - private SelectionManagerFactory() { - managers = new HashMap<IWorkbenchWindow, DefaultJpaSelectionManager>(); - windowListener = new WindowListener(); - } - - private void init() { - IWorkbench workbench = PlatformUI.getWorkbench(); - workbench.addWindowListener(windowListener); - } - - /** - * Returns the JpaSelectionManager for the IWorkbenchWindow. - * Creates a new one if none exists yet. - */ - DefaultJpaSelectionManager internalGetSelectionManager(IWorkbenchWindow window) { - if (window == null) { - throw new IllegalArgumentException("The IWorkbenchWindow cannot be null"); //$NON-NLS-1$ - } - - if (! managers.containsKey(window)) { - DefaultJpaSelectionManager manager = new DefaultJpaSelectionManager(); - this.managers.put(window, manager); - manager.init(window); - } - - return managers.get(window); - } - - - class WindowListener implements IWindowListener - { - public void windowOpened(IWorkbenchWindow aWindow) { - // do nothing - } - - public void windowClosed(IWorkbenchWindow aWindow) { - DefaultJpaSelectionManager manager = internalGetSelectionManager(aWindow); - manager.dispose(); - managers.remove(aWindow); - } - - public void windowActivated(IWorkbenchWindow aWindow) { - // do nothing - } - - public void windowDeactivated(IWorkbenchWindow aWindow) { - // do nothing - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java deleted file mode 100644 index dbc24cc8b2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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.jpa.ui.internal.selection; - -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IPropertyListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.texteditor.ITextEditor; - -public class TextEditorSelectionParticipant - implements JpaSelectionParticipant -{ - private final JpaSelectionManager selectionManager; - - final ITextEditor textEditor; - - private final IPropertyListener editorInputListener; - - private final ISelectionChangedListener editorSelectionListener; - - private JpaSelection currentSelection; - - private boolean forwardSelection = true; // TODO this just smells wrong ~bjv - - - public TextEditorSelectionParticipant(JpaSelectionManager selectionManager, ITextEditor textEditor) { - super(); - this.selectionManager = selectionManager; - this.textEditor = textEditor; - this.editorInputListener = new EditorInputListener(); - this.textEditor.addPropertyListener(this.editorInputListener); - this.editorSelectionListener = new EditorSelectionListener(); - this.getPostSelectionProvider().addPostSelectionChangedListener(this.editorSelectionListener); - this.currentSelection = this.calculateSelection(); - } - - // ********** IJpaSelectionParticipant implementation ********** - - public JpaSelection getSelection() { - return this.currentSelection; - } - - public void selectionChanged(JpaSelectionEvent evt) { - JpaSelection newSelection = evt.getSelection(); - - if ((newSelection == JpaSelection.NULL_SELECTION) - || newSelection.equals(this.currentSelection)) { - return; - } - - if (getActiveTextEditor() != this.textEditor) { - return; - } - - this.forwardSelection = false; - TextRange textRange = newSelection.getSelectedNode().getSelectionTextRange(); - if (textRange != null) { - this.textEditor.selectAndReveal(textRange.getOffset(), textRange.getLength()); - this.currentSelection = newSelection; - } - this.forwardSelection = true; - } - - public boolean disposeOnHide() { - return true; - } - - public void dispose() { - this.textEditor.removePropertyListener(this.editorInputListener); - this.getPostSelectionProvider().removePostSelectionChangedListener(this.editorSelectionListener); - } - - - // ********** internal methods ********** - - protected JpaSelection calculateSelection() { - ISelection selection = this.textEditor.getSelectionProvider().getSelection(); - if (! (selection instanceof ITextSelection)) { - return JpaSelection.NULL_SELECTION; - } - - JpaFile jpaFile = this.getJpaFile(); - if (jpaFile == null) { - return JpaSelection.NULL_SELECTION; - } - - return this.buildSelection(jpaFile.getStructureNode(((ITextSelection) selection).getOffset())); - } - - protected JpaSelection buildSelection(JpaStructureNode selectedNode) { - return (selectedNode == null) ? JpaSelection.NULL_SELECTION : new DefaultJpaSelection(selectedNode); - } - - protected IWorkbenchPage getActivePage() { - return this.textEditor.getEditorSite().getWorkbenchWindow().getActivePage(); - } - - protected IWorkbenchPart getActivePart() { - IWorkbenchPage activePage = getActivePage(); - return (activePage == null) ? null: activePage.getActivePart(); - } - - protected IEditorPart getActiveEditor() { - IWorkbenchPage activePage = getActivePage(); - return (activePage == null) ? null: activePage.getActiveEditor(); - } - - protected ITextEditor getActiveTextEditor() { - return getTextEditor(getActiveEditor()); - } - - protected ITextEditor getTextEditor(IWorkbenchPart part) { - return (part == null) ? null : (ITextEditor) part.getAdapter(ITextEditor.class); - } - - protected JpaFile getJpaFile() { - IEditorInput input = this.textEditor.getEditorInput(); - if ( ! (input instanceof IFileEditorInput)) { - return null; - } - return JptJpaCorePlugin.getJpaFile(((IFileEditorInput) input).getFile()); - } - - protected IPostSelectionProvider getPostSelectionProvider() { - return (IPostSelectionProvider) this.textEditor.getSelectionProvider(); - } - - - // ********** listener callbacks ********** - - protected void editorInputChanged() { - this.selectionChanged(); - } - - protected void editorSelectionChanged(SelectionChangedEvent event) { - // This is a bit kludgey. We check to see if the selection event - // occurred when a participating part is active (and so, ostensibly, - // *because* of the participating part). If so, we reselect the valid - // text. - IWorkbenchPart activePart = getActivePart(); - if (getTextEditor(activePart) != this.textEditor && this.selectionManager.isRegistered(activePart)) { - if (this.currentSelection.isEmpty()) { - return; - } - - this.forwardSelection = false; - TextRange textRange = this.currentSelection.getSelectedNode().getSelectionTextRange(); - if (textRange != null) { - this.textEditor.selectAndReveal(textRange.getOffset(), textRange.getLength()); - } - this.forwardSelection = true; - - return; - } - - this.selectionChanged(); - } - - protected void selectionChanged() { - JpaSelection newSelection = this.calculateSelection(); - if (newSelection.equals(this.currentSelection)) { - return; - } - this.currentSelection = newSelection; - - if (this.forwardSelection) { - this.selectionManager.select(newSelection, this); - } - } - - - // ********** listeners ********** - - protected class EditorInputListener implements IPropertyListener { - protected EditorInputListener() { - super(); - } - public void propertyChanged(Object source, int propId) { - if ((source == TextEditorSelectionParticipant.this.textEditor) - && (propId == IEditorPart.PROP_INPUT)) { - TextEditorSelectionParticipant.this.editorInputChanged(); - } - } - } - - - protected class EditorSelectionListener implements ISelectionChangedListener { - protected EditorSelectionListener() { - super(); - } - public void selectionChanged(SelectionChangedEvent event) { - TextEditorSelectionParticipant.this.editorSelectionChanged(event); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/WorkbenchPartAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/WorkbenchPartAdapterFactory.java deleted file mode 100644 index bea07321cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/WorkbenchPartAdapterFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.selection; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jpt.jpa.ui.internal.views.JpaDetailsView; -import org.eclipse.jpt.jpa.ui.internal.views.structure.JpaStructureView; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Factory to build adapters for a workbench part: - * - JPA selection participant (if the editor part is a text editor etc.) - * - * See org.eclipse.jpt.jpa.ui plugin.xml. - */ -public class WorkbenchPartAdapterFactory - implements IAdapterFactory -{ - private static final Class<?>[] ADAPTER_LIST = new Class[] { JpaSelectionParticipant.class }; - - public Class<?>[] getAdapterList() { - return ADAPTER_LIST; - } - - public Object getAdapter(Object adaptableObject, @SuppressWarnings("unchecked") Class adapterType) { - if (adaptableObject instanceof IWorkbenchPart) { - return this.getAdapter((IWorkbenchPart) adaptableObject, adapterType); - } - return null; - } - - private Object getAdapter(IWorkbenchPart workbenchPart, Class<?> adapterType) { - if (adapterType == JpaSelectionParticipant.class) { - return this.buildJpaSelectionParticipant(workbenchPart); - } - return null; - } - - private JpaSelectionParticipant buildJpaSelectionParticipant(IWorkbenchPart workbenchPart) { - JpaSelectionManager selectionManager = SelectionManagerFactory.getSelectionManager(workbenchPart.getSite().getWorkbenchWindow()); - if (workbenchPart instanceof ITextEditor) { - return new TextEditorSelectionParticipant(selectionManager, (ITextEditor) workbenchPart); - } - if (workbenchPart instanceof JpaStructureView) { - return new JpaStructureSelectionParticipant(selectionManager, (JpaStructureView) workbenchPart); - } - if (workbenchPart instanceof JpaDetailsView) { - return new JpaDetailsSelectionParticipant((JpaDetailsView) workbenchPart); - } - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/GeneralJpaMappingItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/GeneralJpaMappingItemLabelProviderFactory.java deleted file mode 100644 index e18da9c246..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/GeneralJpaMappingItemLabelProviderFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - ******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistentAttributeItemLabelProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistentTypeItemLabelProvider; - -public abstract class GeneralJpaMappingItemLabelProviderFactory - implements ItemLabelProviderFactory -{ - public ItemLabelProvider buildItemLabelProvider( - Object item, DelegatingContentAndLabelProvider labelProvider) { - if (item instanceof PersistentType) { - return new PersistentTypeItemLabelProvider((PersistentType) item, labelProvider); - } - if (item instanceof ReadOnlyPersistentAttribute) { - return new PersistentAttributeItemLabelProvider((ReadOnlyPersistentAttribute) item, labelProvider); - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaItemContentProviderFactory.java deleted file mode 100644 index c9d19d7812..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaItemContentProviderFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.JavaPersistentTypeItemContentProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistentAttributeItemContentProvider; - - -public class JavaItemContentProviderFactory implements TreeItemContentProviderFactory -{ - public TreeItemContentProvider buildItemContentProvider( - Object item, DelegatingContentAndLabelProvider contentProvider) { - DelegatingTreeContentAndLabelProvider treeContentProvider = (DelegatingTreeContentAndLabelProvider) contentProvider; - if (item instanceof JpaFile) { - return new ResourceModelItemContentProvider((JpaFile) item, treeContentProvider); - } - if (item instanceof JavaPersistentType) { - return new JavaPersistentTypeItemContentProvider((JavaPersistentType) item, treeContentProvider); - } - if (item instanceof JavaPersistentAttribute) { - return new PersistentAttributeItemContentProvider((JavaPersistentAttribute) item, treeContentProvider); - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaItemLabelProviderFactory.java deleted file mode 100644 index ed3c54199f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaItemLabelProviderFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.jpa.ui.internal.structure; - - -public class JavaItemLabelProviderFactory extends GeneralJpaMappingItemLabelProviderFactory -{ - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaResourceModelStructureProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaResourceModelStructureProvider.java deleted file mode 100644 index 0d07161408..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/JavaResourceModelStructureProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class JavaResourceModelStructureProvider - implements JpaStructureProvider -{ - // singleton - private static final JpaStructureProvider INSTANCE = new JavaResourceModelStructureProvider(); - - - /** - * Return the singleton - */ - public static JpaStructureProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private JavaResourceModelStructureProvider() { - super(); - } - - public TreeItemContentProviderFactory getTreeItemContentProviderFactory() { - return new JavaItemContentProviderFactory(); - } - - public ItemLabelProviderFactory getItemLabelProviderFactory() { - return new JavaItemLabelProviderFactory(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmItemContentProviderFactory.java deleted file mode 100644 index 5b3de90068..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmItemContentProviderFactory.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.OrmPersistentTypeItemContentProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistentAttributeItemContentProvider; - -public class OrmItemContentProviderFactory implements TreeItemContentProviderFactory -{ - public TreeItemContentProvider buildItemContentProvider( - Object item, DelegatingContentAndLabelProvider contentProvider) { - DelegatingTreeContentAndLabelProvider treeContentProvider = (DelegatingTreeContentAndLabelProvider) contentProvider; - if (item instanceof JpaFile) { - return new ResourceModelItemContentProvider((JpaFile) item, treeContentProvider); - } - if (item instanceof EntityMappings) { - return new EntityMappingsItemContentProvider((EntityMappings) item, treeContentProvider); - } - if (item instanceof OrmPersistentType) { - return new OrmPersistentTypeItemContentProvider((OrmPersistentType) item, treeContentProvider); - } - if (item instanceof OrmPersistentAttribute) { - return new PersistentAttributeItemContentProvider((OrmPersistentAttribute) item, treeContentProvider); - } - return null; - } - - public static class EntityMappingsItemContentProvider extends AbstractTreeItemContentProvider<OrmPersistentType> - { - public EntityMappingsItemContentProvider( - EntityMappings entityMappings, DelegatingTreeContentAndLabelProvider contentProvider) { - super(entityMappings, contentProvider); - } - - @Override - public EntityMappings getModel() { - return (EntityMappings) super.getModel(); - } - - @Override - public Object getParent() { - // I'd like to return the resource model here, but that involves a hefty - // API change - we'll see what happens with this code first - return null; - } - - @Override - protected CollectionValueModel<OrmPersistentType> buildChildrenModel() { - return new ListCollectionValueModelAdapter<OrmPersistentType>( - new ListAspectAdapter<EntityMappings, OrmPersistentType>( - EntityMappings.PERSISTENT_TYPES_LIST, getModel()) { - @Override - protected ListIterable<OrmPersistentType> getListIterable() { - return this.subject.getPersistentTypes(); - } - }); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmItemLabelProviderFactory.java deleted file mode 100644 index b4d21ac29a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmItemLabelProviderFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.EntityMappingsItemLabelProvider; - -public class OrmItemLabelProviderFactory extends GeneralJpaMappingItemLabelProviderFactory -{ - @Override - public ItemLabelProvider buildItemLabelProvider( - Object item, DelegatingContentAndLabelProvider labelProvider) { - if (item instanceof EntityMappings) { - return new EntityMappingsItemLabelProvider((EntityMappings) item, labelProvider); - } - return super.buildItemLabelProvider(item, labelProvider); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmResourceModelStructureProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmResourceModelStructureProvider.java deleted file mode 100644 index b48afb9177..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/OrmResourceModelStructureProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class OrmResourceModelStructureProvider - implements JpaStructureProvider -{ - // singleton - private static final JpaStructureProvider INSTANCE = new OrmResourceModelStructureProvider(); - - - /** - * Return the singleton - */ - public static JpaStructureProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private OrmResourceModelStructureProvider() { - super(); - } - - - public TreeItemContentProviderFactory getTreeItemContentProviderFactory() { - return new OrmItemContentProviderFactory(); - } - - public ItemLabelProviderFactory getItemLabelProviderFactory() { - return new OrmItemLabelProviderFactory(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceItemContentProviderFactory.java deleted file mode 100644 index ec0f08e2a7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceItemContentProviderFactory.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.structure; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; -import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; - -public class PersistenceItemContentProviderFactory - implements TreeItemContentProviderFactory -{ - public TreeItemContentProvider buildItemContentProvider( - Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - DelegatingTreeContentAndLabelProvider treeContentProvider = (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider; - if (item instanceof JpaFile) { - return new ResourceModelItemContentProvider((JpaFile) item, treeContentProvider); - } - else if (item instanceof Persistence) { - return new PersistenceItemContentProvider((Persistence) item, treeContentProvider); - } - else if (item instanceof PersistenceUnit) { - return new PersistenceUnitItemContentProvider((PersistenceUnit) item, treeContentProvider); - } - else if (item instanceof MappingFileRef) { - return new MappingFileRefItemContentProvider((MappingFileRef) item, treeContentProvider); - } - else if (item instanceof ClassRef) { - return new ClassRefItemContentProvider((ClassRef) item, treeContentProvider); - } - else if (item instanceof JarFileRef) { - return new JarFileRefItemContentProvider((JarFileRef) item, treeContentProvider); - } - return null; - } - - - public static class PersistenceItemContentProvider extends AbstractTreeItemContentProvider<PersistenceUnit> - { - public PersistenceItemContentProvider( - Persistence persistence, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistence, contentProvider); - } - - @Override - public Persistence getModel() { - return (Persistence) super.getModel(); - } - - @Override - public Object getParent() { - // I'd like to return the resource model here, but that involves a hefty - // API change - we'll see what happens with this code first - return null; - } - - @Override - protected CollectionValueModel<PersistenceUnit> buildChildrenModel() { - return new ListCollectionValueModelAdapter<PersistenceUnit>( - new ListAspectAdapter<Persistence, PersistenceUnit>(Persistence.PERSISTENCE_UNITS_LIST, getModel()) { - @Override - protected ListIterator<PersistenceUnit> listIterator_() { - return subject.persistenceUnits(); - } - @Override - protected int size_() { - return subject.persistenceUnitsSize(); - } - }); - } - } - - - public static class PersistenceUnitItemContentProvider extends AbstractTreeItemContentProvider<JpaStructureNode> - { - public PersistenceUnitItemContentProvider( - PersistenceUnit persistenceUnit, DelegatingTreeContentAndLabelProvider contentProvider) { - super(persistenceUnit, contentProvider); - } - - @Override - public PersistenceUnit getModel() { - return (PersistenceUnit) super.getModel(); - } - - @Override - public Persistence getParent() { - return getModel().getParent(); - } - - @Override - protected CollectionValueModel<JpaStructureNode> buildChildrenModel() { - ListValueModel<MappingFileRef> specifiedMappingFileLvm = - new ListAspectAdapter<PersistenceUnit, MappingFileRef>( - PersistenceUnit.SPECIFIED_MAPPING_FILE_REFS_LIST, - getModel()) { - @Override - protected ListIterator<MappingFileRef> listIterator_() { - return subject.specifiedMappingFileRefs(); - } - @Override - protected int size_() { - return subject.specifiedMappingFileRefsSize(); - } - }; - - ListValueModel<MappingFileRef> impliedMappingFileCvm = - new PropertyListValueModelAdapter<MappingFileRef>( - new PropertyAspectAdapter<PersistenceUnit, MappingFileRef>( - PersistenceUnit.IMPLIED_MAPPING_FILE_REF_PROPERTY, - getModel()) { - @Override - protected MappingFileRef buildValue_() { - return subject.getImpliedMappingFileRef(); - } - } - ); - ListValueModel<ClassRef> specifiedClassCvm = - new ListAspectAdapter<PersistenceUnit, ClassRef>( - PersistenceUnit.SPECIFIED_CLASS_REFS_LIST, - getModel()) { - @Override - protected ListIterator<ClassRef> listIterator_() { - return subject.specifiedClassRefs(); - } - @Override - protected int size_() { - return subject.specifiedClassRefsSize(); - } - }; - ListValueModel<ClassRef> impliedClassCvm = - new CollectionListValueModelAdapter<ClassRef>( - new CollectionAspectAdapter<PersistenceUnit, ClassRef>( - PersistenceUnit.IMPLIED_CLASS_REFS_COLLECTION, - getModel()) { - @Override - protected Iterator<ClassRef> iterator_() { - return subject.impliedClassRefs(); - } - @Override - protected int size_() { - return subject.impliedClassRefsSize(); - } - }); - ListValueModel<JarFileRef> jarFileCvm = - new ListAspectAdapter<PersistenceUnit, JarFileRef>( - PersistenceUnit.JAR_FILE_REFS_LIST, - getModel()) { - @Override - protected ListIterator<JarFileRef> listIterator_() { - return subject.jarFileRefs(); - } - @Override - protected int size_() { - return subject.jarFileRefsSize(); - } - }; - List<ListValueModel<? extends JpaStructureNode>> list = new ArrayList<ListValueModel<? extends JpaStructureNode>>(4); - list.add(specifiedMappingFileLvm); - list.add(impliedMappingFileCvm); - list.add(specifiedClassCvm); - list.add(impliedClassCvm); - list.add(jarFileCvm); - - return new ListCollectionValueModelAdapter<JpaStructureNode>( - new CompositeListValueModel - <ListValueModel<? extends JpaStructureNode>, JpaStructureNode> - (list)); - } - } - - - public static class MappingFileRefItemContentProvider extends AbstractTreeItemContentProvider<MappingFileRef> - { - public MappingFileRefItemContentProvider( - MappingFileRef mappingFileRef, DelegatingTreeContentAndLabelProvider contentProvider) { - super(mappingFileRef, contentProvider); - } - - @Override - public MappingFileRef getModel() { - return (MappingFileRef) super.getModel(); - } - - @Override - public Object getParent() { - return getModel().getPersistenceUnit(); - } - - @Override - public boolean hasChildren() { - return false; - } - } - - - public static class ClassRefItemContentProvider extends AbstractTreeItemContentProvider<ClassRef> - { - public ClassRefItemContentProvider( - ClassRef classRef, DelegatingTreeContentAndLabelProvider contentProvider) { - super(classRef, contentProvider); - } - - @Override - public ClassRef getModel() { - return (ClassRef) super.getModel(); - } - - @Override - public Object getParent() { - return getModel().getPersistenceUnit(); - } - - @Override - public boolean hasChildren() { - return false; - } - } - - - public static class JarFileRefItemContentProvider extends AbstractTreeItemContentProvider<JarFileRef> - { - public JarFileRefItemContentProvider( - JarFileRef jarFileRef, DelegatingTreeContentAndLabelProvider contentProvider) { - super(jarFileRef, contentProvider); - } - - @Override - public JarFileRef getModel() { - return (JarFileRef) super.getModel(); - } - - @Override - public Object getParent() { - return getModel().getPersistenceUnit(); - } - - @Override - public boolean hasChildren() { - return false; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceItemLabelProviderFactory.java deleted file mode 100644 index f7b35ae415..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceItemLabelProviderFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; -import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.ClassRefItemLabelProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.JarFileRefItemLabelProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.MappingFileRefItemLabelProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistenceItemLabelProvider; -import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistenceUnitItemLabelProvider; - -public class PersistenceItemLabelProviderFactory - implements ItemLabelProviderFactory -{ - public ItemLabelProvider buildItemLabelProvider( - Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - if (item instanceof Persistence) { - return new PersistenceItemLabelProvider((Persistence) item, contentAndLabelProvider); - } - else if (item instanceof PersistenceUnit) { - return new PersistenceUnitItemLabelProvider((PersistenceUnit) item, contentAndLabelProvider); - } - else if (item instanceof MappingFileRef) { - return new MappingFileRefItemLabelProvider((MappingFileRef) item, contentAndLabelProvider); - } - else if (item instanceof ClassRef) { - return new ClassRefItemLabelProvider((ClassRef) item, contentAndLabelProvider); - } - else if (item instanceof JarFileRef) { - return new JarFileRefItemLabelProvider((JarFileRef) item, contentAndLabelProvider); - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceResourceModelStructureProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceResourceModelStructureProvider.java deleted file mode 100644 index f69524ca05..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/PersistenceResourceModelStructureProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.structure; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; - -public class PersistenceResourceModelStructureProvider - implements JpaStructureProvider -{ - // singleton - private static final JpaStructureProvider INSTANCE = new PersistenceResourceModelStructureProvider(); - - - /** - * Return the singleton - */ - public static JpaStructureProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private PersistenceResourceModelStructureProvider() { - super(); - } - - - public TreeItemContentProviderFactory getTreeItemContentProviderFactory() { - return new PersistenceItemContentProviderFactory(); - } - - public ItemLabelProviderFactory getItemLabelProviderFactory() { - return new PersistenceItemLabelProviderFactory(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/ResourceModelItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/ResourceModelItemContentProvider.java deleted file mode 100644 index ef3a7db03a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/structure/ResourceModelItemContentProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.jpa.ui.internal.structure; - -import java.util.Iterator; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaStructureNode; - -public class ResourceModelItemContentProvider extends AbstractTreeItemContentProvider<JpaStructureNode> -{ - public ResourceModelItemContentProvider( - JpaFile jpaFile, - DelegatingTreeContentAndLabelProvider contentProvider) { - super(jpaFile, contentProvider); - } - - @Override - public Object getParent() { - return null; - } - - @Override - public JpaFile getModel() { - return (JpaFile) super.getModel(); - } - - @Override - protected CollectionValueModel<JpaStructureNode> buildChildrenModel() { - return new CollectionAspectAdapter<JpaFile, JpaStructureNode>( - buildJpaFileValueModel(), JpaFile.ROOT_STRUCTURE_NODES_COLLECTION) { - @Override - protected Iterator<JpaStructureNode> iterator_() { - return subject.rootStructureNodes(); - } - }; - } - - protected PropertyValueModel<JpaFile> buildJpaFileValueModel() { - return new SimplePropertyValueModel<JpaFile>(this.getModel()); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/AbstractJpaView.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/AbstractJpaView.java deleted file mode 100644 index 9c4a2e4be4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/AbstractJpaView.java +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2009 Versant. 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: Versant and Others. - initial API and implementation - ********************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.views; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.FormWidgetFactory; -import org.eclipse.jpt.common.ui.internal.widgets.PropertySheetWidgetFactory; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; - -/** - * This is the abstract implementation of the JPA view. The selection is changed - * by receiving a <code>IJpaSelection</code>. - * - * @see JpaSelection - * - * @version 2.0 - * @since 1.0 - */ -public abstract class AbstractJpaView extends ViewPart -{ - /** - * The default page used when nothing can be shown. - */ - private Composite defaultComposite; - - /** - * The string to display when there is no view content - */ - private String defaultLabel; - - /** - * The container of the current page. - */ - private PageBook pageBook; - - private ScrolledForm scrolledForm; - - - /** - * The factory used to create the various widgets. - */ - private WidgetFactory widgetFactory; - - /** - * Creates a new <code>AbstractJpaView</code>. - * - * @param defaultLabel - */ - public AbstractJpaView(String defaultLabel) { - super(); - this.defaultLabel = defaultLabel; - this.initialize(); - } - - private Composite buildDefaultComposite() { - Composite composite = widgetFactory.createComposite(pageBook); - composite.setLayout(new FillLayout(SWT.VERTICAL)); - getWidgetFactory().createLabel(composite, defaultLabel); - return composite; - } - - @Override - public final void createPartControl(Composite parent) { - this.scrolledForm = getFormWidgetFactory().createScrolledForm(parent); - JptJpaUiPlugin.instance().controlAffectsJavaSource(this.scrolledForm); - this.scrolledForm.getBody().setLayout(new GridLayout()); - - this.pageBook = new PageBook(this.scrolledForm.getBody(), SWT.NONE); - GridData gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.horizontalAlignment = SWT.FILL; - this.pageBook.setLayoutData(gridData); - this.scrolledForm.setContent(this.pageBook); - - this.defaultComposite = buildDefaultComposite(); - this.pageBook.showPage(this.defaultComposite); - - subcreatePartControl(parent); - - JpaSelectionManager selectionManager = - SelectionManagerFactory.getSelectionManager(getViewSite().getWorkbenchWindow()); - - selectionManager.register(this); - select(selectionManager.getCurrentSelection()); - } - - protected final PageBook getPageBook() { - return this.pageBook; - } - - public final WidgetFactory getWidgetFactory() { - return this.widgetFactory; - } - - /** - * Initializes this JPA view. - */ - protected void initialize() { - this.widgetFactory = new PropertySheetWidgetFactory( - new TabbedPropertySheetWidgetFactory() - ); - } - - private FormToolkit getFormWidgetFactory() { - return ((FormWidgetFactory) widgetFactory).getWidgetFactory(); - } - - /** - * The selection has changed, update the current page by using the given - * selection state. - * - * @param jpaSelection The new selection used to update this JPA view - */ - public abstract void select(JpaSelection jpaSelection); - - /* - * (non-Javadoc) - */ - @Override - public void setFocus() { - pageBook.setFocus(); - } - - /** - * Changes the current page and show the default one. - */ - protected void showDefaultPage() { - showPage(defaultComposite); - } - - /** - * Changes the current page and show the given one. - * - * @param page The new page to show, <code>null</code> can't be passed - */ - protected final void showPage(Control page) { - page.setParent(this.pageBook); - this.pageBook.showPage(page); - this.scrolledForm.reflow(true); - } - - protected void subcreatePartControl(@SuppressWarnings("unused") Composite parent) { - // no op - for subclasses to override if wished - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java deleted file mode 100644 index 2cd756e9e4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/JpaDetailsView.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.views; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; - -/** - * The JPA view that shows the details of a structure node - * - * @version 2.2 - * @since 1.0 - */ -public class JpaDetailsView extends AbstractJpaView -{ - /** - * The current <code>JpaDetailsPage</code> that was retrieve based on the - * current selection. - */ - private JpaDetailsPage<JpaStructureNode> currentPage; - - /** - * The current selection used to show the right <code>IJpaDetailsPage</code>. - */ - private JpaSelection currentSelection; - - //TODO this is crap, a Map of Maps of Maps. Needs to be done differently, the factory/platform should handle caching instead - // key1 platform id - // key2 JpaResourceType - // key3 structure node type - // value Composite page - private Map<String, Map<JptResourceType, Map<String, JpaDetailsPage<? extends JpaStructureNode>>>> detailsPages; - - /** - * Creates a new <code>JpaDetailsView</code>. - */ - public JpaDetailsView() { - super(JptUiMessages.JpaDetailsView_viewNotAvailable); - } - - @Override - protected void initialize() { - super.initialize(); - - this.currentSelection = JpaSelection.NULL_SELECTION; - this.detailsPages = new HashMap<String, Map<JptResourceType, Map<String, JpaDetailsPage<? extends JpaStructureNode>>>>(); - } - - private JpaPlatformUi getJpaPlatformUi(JpaStructureNode structureNode) { - String platformId = structureNode.getJpaProject().getJpaPlatform().getId(); - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(platformId); - } - - public JpaSelection getSelection() { - return this.currentSelection; - } - - private JpaDetailsPage<? extends JpaStructureNode> getDetailsPage(JpaStructureNode structureNode) { - String platformId = structureNode.getJpaProject().getJpaPlatform().getId(); - if (this.detailsPages.containsKey(platformId)) { - Map<JptResourceType, Map<String, JpaDetailsPage<? extends JpaStructureNode>>> platformDetailsPages = this.detailsPages.get(platformId); - Map<String, JpaDetailsPage<? extends JpaStructureNode>> contentTypeDetailsPages = platformDetailsPages.get(structureNode.getResourceType()); - if (contentTypeDetailsPages != null) { - JpaDetailsPage<? extends JpaStructureNode> page = contentTypeDetailsPages.get(structureNode.getId()); - if (page != null) { - if (page.getControl().isDisposed()) { - platformDetailsPages.remove(structureNode.getId()); - } else { - return page; - } - } - } - } - return buildDetailsPage(structureNode); - } - - private JpaDetailsPage<? extends JpaStructureNode> buildDetailsPage(JpaStructureNode structureNode) { - JpaPlatformUi jpaPlatformUi = getJpaPlatformUi(structureNode); - - Composite container = getWidgetFactory().createComposite(getPageBook()); - container.setLayout(new FillLayout(SWT.HORIZONTAL)); - - JpaDetailsPage<? extends JpaStructureNode> page = jpaPlatformUi.buildJpaDetailsPage(container, structureNode, getWidgetFactory()); - if (page == null) { - return null; - } - - String platformId = structureNode.getJpaProject().getJpaPlatform().getId(); - Map<JptResourceType, Map<String, JpaDetailsPage<? extends JpaStructureNode>>> platformDetailsPages = this.detailsPages.get(platformId); - if (platformDetailsPages == null) { - platformDetailsPages = new HashMap<JptResourceType, Map<String, JpaDetailsPage<? extends JpaStructureNode>>>(); - this.detailsPages.put(platformId, platformDetailsPages); - } - JptResourceType resourceType = structureNode.getResourceType(); - Map<String, JpaDetailsPage<? extends JpaStructureNode>> contentTypeDetailsPages = platformDetailsPages.get(resourceType); - if (contentTypeDetailsPages == null) { - contentTypeDetailsPages = new HashMap<String, JpaDetailsPage<? extends JpaStructureNode>>(); - platformDetailsPages.put(resourceType, contentTypeDetailsPages); - } - contentTypeDetailsPages.put(structureNode.getId(), page); - - return page; - } - - @Override - @SuppressWarnings("unchecked") - public void select(JpaSelection jpaSelection) { - if (jpaSelection.equals(this.currentSelection)) { - return; - } - - this.currentSelection = jpaSelection; - if (jpaSelection == JpaSelection.NULL_SELECTION) { - if (this.currentPage != null) { - this.currentPage.setSubject(null); - this.setCurrentPage(null); - } - return; - } - JpaStructureNode newNode = jpaSelection.getSelectedNode(); - JpaDetailsPage<JpaStructureNode> newPage = (JpaDetailsPage<JpaStructureNode>) getDetailsPage(newNode); - if (this.currentPage != null && this.currentPage != newPage){ - try { - this.currentPage.setSubject(null); - } catch (Exception e) { - JptJpaUiPlugin.log(e); - } - } - if (newPage != null) { - try { - newPage.setSubject(newNode); - } catch (Exception e) { - newPage = null;// Show error page - JptJpaUiPlugin.log(e); - } - } - setCurrentPage(newPage); - } - - /** - * Changes the current page and shows the given page. - * - * @param newPage The new page to display - */ - private void setCurrentPage(JpaDetailsPage<JpaStructureNode> newPage) { - this.currentPage = newPage; - - // Show new page - if (newPage == null) { - showDefaultPage(); - } - else { - showPage(newPage.getControl()); - } - } - - @Override - public void dispose() { - for (Map<JptResourceType, Map<String, JpaDetailsPage<? extends JpaStructureNode>>> resourceTypeMap : this.detailsPages.values()) { - for (Map<String, JpaDetailsPage<? extends JpaStructureNode>> detailsPageMap : resourceTypeMap.values()) { - for (JpaDetailsPage<? extends JpaStructureNode> detailsPage : detailsPageMap.values()) { - detailsPage.dispose(); - } - } - } - this.detailsPages.clear(); - - this.currentSelection = JpaSelection.NULL_SELECTION; - this.currentPage = null; - - super.dispose(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/structure/JpaStructurePage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/structure/JpaStructurePage.java deleted file mode 100644 index 5e8b53edfe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/structure/JpaStructurePage.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.views.structure; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent; -import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent; -import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent; -import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent; -import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JpaProjectManager; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelection; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.part.Page; - -public class JpaStructurePage - extends Page - implements ISelectionProvider -{ - private final JpaStructureView jpaStructureView; - - JpaFile jpaFile; - - private final IFile file; - - private JpaProject jpaProject; - - private final JpaStructureProvider structureProvider; - - private Composite control; - - private DelegatingContentAndLabelProvider contentAndLabelProvider; - - TreeViewer viewer; - - private final ListenerList selectionChangedListenerList; - - private final ISelectionChangedListener treeSelectionListener; - - private final ISelectionChangedListener treePostSelectionListener; - - private final CollectionChangeListener projectsListener; - - private final CollectionChangeListener jpaFilesListener; - - - public JpaStructurePage( - JpaStructureView jpaStructureView, JpaFile jpaFile, JpaStructureProvider structureProvider) { - - this.jpaStructureView = jpaStructureView; - this.jpaFile = jpaFile; - this.jpaProject = jpaFile.getJpaProject(); - this.file = jpaFile.getFile(); - this.structureProvider = structureProvider; - this.selectionChangedListenerList = new ListenerList(); - this.treeSelectionListener = new TreeSelectionChangedListener(); - this.treePostSelectionListener = new TreePostSelectionChangedListener(); - this.projectsListener = buildProjectsListener(); - this.jpaFilesListener = buildJpaFilesListener(); - } - - - private CollectionChangeListener buildProjectsListener() { - return new CollectionChangeListener(){ - - public void itemsRemoved(CollectionRemoveEvent event) { - JpaStructurePage.this.projectsRemoved(event); - } - - public void itemsAdded(CollectionAddEvent event) { - JpaStructurePage.this.projectsAdded(event); - } - - public void collectionCleared(CollectionClearEvent event) { - JpaStructurePage.this.projectsCleared(event); - } - - public void collectionChanged(CollectionChangeEvent event) { - JpaStructurePage.this.projectsChanged(event); - } - }; - } - - @SuppressWarnings("unchecked") - void projectsRemoved(CollectionRemoveEvent event) { - for (JpaProject item : (Iterable<JpaProject>) event.getItems()) { - if (item.getProject() == JpaStructurePage.this.file.getProject()) { - setJpaProject(null); - break; - } - } - } - - @SuppressWarnings("unchecked") - void projectsAdded(CollectionAddEvent event) { - for (JpaProject item : (Iterable<JpaProject>) event.getItems()) { - if (item.getProject() == JpaStructurePage.this.file.getProject()) { - setJpaProject(item); - break; - } - } - } - - void projectsCleared(@SuppressWarnings("unused") CollectionClearEvent event) { - setJpaProject(null); - } - - void projectsChanged(@SuppressWarnings("unused") CollectionChangeEvent event) { - setJpaProject(JptJpaCorePlugin.getJpaProject(this.file.getProject())); - } - - private CollectionChangeListener buildJpaFilesListener() { - return new CollectionChangeListener(){ - - public void itemsRemoved(CollectionRemoveEvent event) { - JpaStructurePage.this.jpaFilesRemoved(event); - } - - public void itemsAdded(CollectionAddEvent event) { - JpaStructurePage.this.jpaFilesAdded(event); - } - - public void collectionCleared(CollectionClearEvent event) { - JpaStructurePage.this.jpaFilesCleared(event); - } - - public void collectionChanged(CollectionChangeEvent event) { - JpaStructurePage.this.jpaFilesChanged(event); - } - }; - } - - @SuppressWarnings("unchecked") - void jpaFilesRemoved(CollectionRemoveEvent event) { - for (JpaFile item : (Iterable<JpaFile>) event.getItems()) { - if (item == JpaStructurePage.this.jpaFile) { - setJpaFile(null); - break; - } - } - } - - @SuppressWarnings("unchecked") - void jpaFilesAdded(CollectionAddEvent event) { - for (JpaFile item : (Iterable<JpaFile>) event.getItems()) { - if (item.getFile() != null && item.getFile().equals(JpaStructurePage.this.file)) { - setJpaFile(item); - break; - } - } - } - - void jpaFilesCleared(@SuppressWarnings("unused") CollectionClearEvent event) { - setJpaFile(null); - } - - void jpaFilesChanged(@SuppressWarnings("unused") CollectionChangeEvent event) { - setJpaFile(this.jpaProject.getJpaFile(this.file)); - } - - private void setJpaProject(JpaProject jpaProject) { - if (this.jpaProject == jpaProject) { - return; - } - if (this.jpaProject != null) { - this.jpaProject.removeCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, this.jpaFilesListener); - } - this.jpaProject = jpaProject; - if (this.jpaProject != null) { - this.jpaProject.addCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, this.jpaFilesListener); - setJpaFile(this.jpaProject.getJpaFile(JpaStructurePage.this.file)); - } - else { - setJpaFile(null); - } - } - - private void setJpaFile(JpaFile jpaFile) { - if (this.jpaFile == jpaFile) { - return; - } - this.jpaFile = jpaFile; - SWTUtil.asyncExec(new Runnable(){ - public void run() { - JpaStructurePage.this.viewer.setInput(JpaStructurePage.this.jpaFile); - } - }); - } - - @Override - public void init(IPageSite pageSite) { - super.init(pageSite); - pageSite.setSelectionProvider(this); - } - - @Override - public void createControl(Composite parent) { - control = new Composite(parent, SWT.NULL); - control.setLayout(new FillLayout()); - viewer = new TreeViewer(control, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setAutoExpandLevel(2); - DelegatingTreeContentAndLabelProvider provider - = new DelegatingTreeContentAndLabelProvider( - structureProvider.getTreeItemContentProviderFactory(), - structureProvider.getItemLabelProviderFactory()); - this.contentAndLabelProvider = provider; - viewer.setContentProvider(provider); - // TODO Use problem decorator - viewer.setLabelProvider(provider); - this.viewer.setInput(this.jpaFile); - engageListeners(); - initContextMenu(); - } - - protected void engageListeners() { - this.viewer.addSelectionChangedListener(this.treeSelectionListener); - this.viewer.addPostSelectionChangedListener(this.treePostSelectionListener); - this.jpaProject.addCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, this.jpaFilesListener); - JptJpaCorePlugin.getJpaProjectManager().addCollectionChangeListener(JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectsListener); - } - - @Override - public void dispose() { - disengageListeners(); - super.dispose(); - } - - protected void disengageListeners() { - JptJpaCorePlugin.getJpaProjectManager().removeCollectionChangeListener(JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectsListener); - if (this.jpaProject != null) { - this.jpaProject.removeCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, this.jpaFilesListener); - } - this.viewer.removePostSelectionChangedListener(this.treePostSelectionListener); - this.viewer.removeSelectionChangedListener(this.treeSelectionListener); - } - - protected void initContextMenu() { - // Create dynamic menu mgr. Dynamic is currently required to - // support action contributions. - MenuManager mgr = new MenuManager(); - mgr.setRemoveAllWhenShown(true); - mgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - JpaStructurePage.this.fillContextMenu(menuManager); - } - }); - Menu menu = mgr.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - this.jpaStructureView.getSite().registerContextMenu(mgr, viewer); - } - - /** - * Called when the context menu is about to open. - * Delegates to the action group using the viewer's selection as the action context. - * @since 2.0 - */ - protected void fillContextMenu(IMenuManager manager) { - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - @Override - public Control getControl() { - return control; - } - - @Override - public void setFocus() { - control.setFocus(); - } - - - - void select(JpaSelection selection) { - if (selection.isEmpty()) { - viewer.setSelection(StructuredSelection.EMPTY); - } - else { - viewer.setSelection(new StructuredSelection(selection.getSelectedNode()), true); - } - } - - - // **************** ISelectionProvider impl ******************************** - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListenerList.add(listener); - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListenerList.remove(listener); - } - - public ITreeSelection getSelection() { - return (ITreeSelection) viewer.getSelection(); - } - - public JpaSelection getJpaSelection() { - ITreeSelection viewerSelection = getSelection(); - - if (viewerSelection.isEmpty() || viewerSelection.size() > 1) { - return JpaSelection.NULL_SELECTION; - } - return new DefaultJpaSelection((JpaStructureNode) viewerSelection.getFirstElement()); - } - - - public void setSelection(ISelection selection) { - if (viewer != null) { - viewer.setSelection(selection); - } - } - - /* - * relays tree selection event to listeners of this page - */ - protected void fireSelectionChanged(ISelection selection) { - // create an event - final SelectionChangedEvent event = - new SelectionChangedEvent(this, selection); - - // fire the event - Object[] listeners = selectionChangedListenerList.getListeners(); - for (int i = 0; i < listeners.length; ++i) { - final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i]; - SafeRunner.run( - new SafeRunnable() { - public void run() { - l.selectionChanged(event); - } - }); - } - } - - protected void updateStatusBar(ISelection selection) { - IStatusLineManager statusLineManager = getSite().getActionBars().getStatusLineManager(); - if (! (selection instanceof IStructuredSelection) || selection.isEmpty()) { - statusLineManager.setMessage(""); //$NON-NLS-1$ - return; - } - IStructuredSelection sselection = (IStructuredSelection) selection; - if (sselection.size() > 1) { - statusLineManager.setMessage(NLS.bind(JptUiMessages.JpaStructureView_numItemsSelected, sselection.size())); - } - else { - Object selObj = sselection.getFirstElement(); - statusLineManager.setMessage( - this.contentAndLabelProvider.getImage(selObj), - this.contentAndLabelProvider.getDescription(selObj)); - } - } - - - class TreeSelectionChangedListener - implements ISelectionChangedListener - { - public void selectionChanged(SelectionChangedEvent event) { - JpaStructurePage.this.fireSelectionChanged(event.getSelection()); - } - } - - - class TreePostSelectionChangedListener - implements ISelectionChangedListener - { - public void selectionChanged(SelectionChangedEvent event) { - JpaStructurePage.this.updateStatusBar(event.getSelection()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/structure/JpaStructureView.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/structure/JpaStructureView.java deleted file mode 100644 index 4fbde058c2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/views/structure/JpaStructureView.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.views.structure; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; -import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.IPage; -import org.eclipse.ui.part.MessagePage; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.part.PageBookView; - -public class JpaStructureView - extends PageBookView -{ - public JpaStructureView() { - super(); - } - - @Override - public void createPartControl(Composite parent) { - super.createPartControl(parent); - - JpaSelectionManager selectionManager = - SelectionManagerFactory.getSelectionManager(this.getViewSite().getWorkbenchWindow()); - - selectionManager.register(this); - this.select(selectionManager.getCurrentSelection()); - } - - @Override - public void partBroughtToTop(IWorkbenchPart part) { - // do same thing as partActivated, which will check to see if the - // part is an editor, in which case, we want to show the right page - partActivated(part); - } - - @Override - protected boolean isImportant(IWorkbenchPart part) { - return part instanceof IEditorPart; - } - - @Override - protected IWorkbenchPart getBootstrapPart() { - IWorkbenchPage page = this.getSite().getPage(); - return (page == null) ? null : page.getActiveEditor(); - } - - @Override - protected IPage createDefaultPage(PageBook book) { - MessagePage page = new MessagePage(); - this.initPage(page); - page.createControl(book); - page.setMessage(JptUiMessages.JpaStructureView_structureNotAvailable); - return page; - } - - @Override - protected PageRec doCreatePage(IWorkbenchPart part) { - // use the platform adapter service so the structure view can be - // associated with any IEditorPart that has an associated adapter - // factory that can give us the JPA file associated with the editor part - // @see org.eclipse.jpt.jpa.ui.internal.EditorPartAdapterFactory - JpaFile jpaFile = (JpaFile) part.getAdapter(JpaFile.class); - if (jpaFile == null) { - return null; - } - - JpaStructureProvider structureProvider = this.getStructureProvider(jpaFile); - if (structureProvider == null) { - return null; - } - - JpaStructurePage page = new JpaStructurePage(this, jpaFile, structureProvider); - this.initPage(page); - page.createControl(this.getPageBook()); - return new PageRec(part, page); - } - - private JpaStructureProvider getStructureProvider(JpaFile jpaFile) { - return this.getPlatformUi(jpaFile).getStructureProvider(jpaFile); - } - - private JpaPlatformUi getPlatformUi(JpaFile jpaFile) { - return JptJpaUiPlugin.instance().getJpaPlatformUi(jpaFile.getJpaProject().getJpaPlatform()); - } - - @Override - protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { - JpaStructurePage page = (JpaStructurePage) pageRecord.page; - page.dispose(); - pageRecord.dispose(); - } - - public JpaSelection getJpaSelection() { - if (this.getCurrentPage() != this.getDefaultPage()) { - return ((JpaStructurePage) this.getCurrentPage()).getJpaSelection(); - } - return JpaSelection.NULL_SELECTION; - } - - public void select(JpaSelection newSelection) { - // correct page should be shown - if (this.getCurrentPage() != this.getDefaultPage()) { - ((JpaStructurePage) this.getCurrentPage()).select(newSelection); - } - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - this.getSelectionProvider().addSelectionChangedListener(listener); - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - this.getSelectionProvider().removeSelectionChangedListener(listener); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/DatabaseSchemaWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/DatabaseSchemaWizardPage.java deleted file mode 100644 index 3c2abe3ebb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/DatabaseSchemaWizardPage.java +++ /dev/null @@ -1,445 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.internal.wizards; - -import java.util.EventListener; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.utility.internal.ListenerList; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.db.ConnectionAdapter; -import org.eclipse.jpt.jpa.db.ConnectionListener; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.properties.JpaProjectPropertiesPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PreferencesUtil; - -/** - * Most of the behavior is in DatabaseGroup.... - * - * We open the wizard page with the JPA project's connection profile and - * default schema selected (if possible), but then the selections are driven - * by the user. If the user re-selects the JPA project's connection profile, - * we will pre-select the project's default schema if possible. - */ -public class DatabaseSchemaWizardPage extends WizardPage { - - final JpaProject jpaProject; - - private final ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class); - - private DatabaseGroup databaseGroup; - - - public DatabaseSchemaWizardPage(JpaProject jpaProject) { - super("Database Schema"); //$NON-NLS-1$ - if (jpaProject == null) { - throw new NullPointerException(); - } - this.jpaProject = jpaProject; - this.setTitle(JptUiMessages.DatabaseSchemaWizardPage_title); - this.setMessage(JptUiMessages.DatabaseSchemaWizardPage_desc); - } - - public void createControl(Composite parent) { - this.setPageComplete(false); - this.setControl(this.buildTopLevelControl(parent)); - } - - private Control buildTopLevelControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - this.databaseGroup = new DatabaseGroup(composite); - Dialog.applyDialogFont(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE_CONNECTION); - return composite; - } - - public ConnectionProfile getJpaProjectConnectionProfile() { - return this.jpaProject.getConnectionProfile(); - } - - public Schema getSelectedSchema() { - return this.databaseGroup.getSelectedSchema(); - } - - @Override - public void dispose() { - this.databaseGroup.dispose(); - super.dispose(); - } - - - // ********** listeners ********** - - public void addListener(Listener listener) { - this.listenerList.add(listener); - } - - public void removeListener(Listener listener) { - this.listenerList.remove(listener); - } - - void fireSchemaChanged(Schema schema) { - this.setPageComplete(schema != null); - for (Listener listener : this.listenerList.getListeners()) { - listener.selectedSchemaChanged(schema); - } - } - - - // ********** listener interface ********** - - /** - * Allows clients to listen for changes to the selected connection profile - * and schema. - */ - public interface Listener extends EventListener { - void selectedSchemaChanged(Schema schema); - } - - - // ********** database group ********** - - /** - * schema combo-box - * add project connection link - * reconnect link - */ - class DatabaseGroup { - - // these are kept in synch with the selection - private Schema selectedSchema; - - private final Combo schemaComboBox; - - private final Link reconnectLink; - - private Link addJpaProjectConnectionLink; - - private final ConnectionListener connectionListener; - - - // ********** construction ********** - - DatabaseGroup(Composite composite) { - super(); - - Group group = new Group(composite, SWT.NONE); - group.setLayout(new GridLayout(2, false)); // false = do not make columns equal width - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - group.setText(JptUiMessages.DatabaseSchemaWizardPage_schemaSettings); - // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp(this.group, JpaHelpContextIds.XXX); - - // schema combo-box - this.buildLabel(group, 1, JptUiMessages.DatabaseSchemaWizardPage_schema); - this.schemaComboBox = this.buildComboBox(group, this.buildSchemaComboBoxSelectionListener()); - - String message = (this.projectHasAConnection()) ? - JptUiMessages.DatabaseSchemaWizardPage_schemaInfo : - JptUiMessages.DatabaseSchemaWizardPage_connectionInfo; - - this.buildLabel(group, 2, message); - - // add project's connection link - if( ! this.projectHasAConnection()) { - this.addJpaProjectConnectionLink = this.buildLink(group, - JptUiMessages.DatabaseSchemaWizardPage_addConnectionToProject, - this.buildAddJpaProjectConnectionLinkListener()); - } - - // reconnect link - this.reconnectLink = this.buildLink(group, JptUiMessages.DatabaseSchemaWizardPage_connectLink, this.buildReconnectLinkSelectionListener()); - this.reconnectLink.setEnabled(true); - - this.selectedSchema = this.getDefaultSchema(); - - if (this.selectedSchema != null) { - DatabaseSchemaWizardPage.this.fireSchemaChanged(this.selectedSchema); - } - - this.connectionListener = this.buildConnectionListener(); - this.addJpaProjectConnectionProfileListener(this.connectionListener); - - this.updateSchemaComboBox(); - this.updateReconnectLink(); - } - - - // ********** intra-wizard methods ********** - - Schema getSelectedSchema() { - return this.selectedSchema; - } - - void dispose() { - if(this.projectHasAConnection()) { - this.getJpaProjectConnectionProfile().removeConnectionListener(this.connectionListener); - } - } - - - // ********** internal methods ********** - - void addJpaProjectConnectionListener() { - this.addJpaProjectConnectionProfileListener(this.connectionListener); - } - - - private void addJpaProjectConnectionProfileListener(ConnectionListener listener) { - if(this.projectHasAConnection()) { - this.getJpaProjectConnectionProfile().addConnectionListener(listener); - } - } - - private boolean projectHasAConnection() { - return this.getJpaProjectConnectionProfile() != null; - } - - /** - * this can return null; - * called at start-up and when the selected connection profile changes - */ - private ConnectionProfile getJpaProjectConnectionProfile() { - return DatabaseSchemaWizardPage.this.jpaProject.getConnectionProfile(); - } - - /** - * this can return null; - * called at start-up and when the selected connection profile changes - */ - private Schema getDefaultSchema() { - return DatabaseSchemaWizardPage.this.jpaProject.getDefaultDbSchema(); - } - - private SchemaContainer getDefaultSchemaContainer() { - return DatabaseSchemaWizardPage.this.jpaProject.getDefaultDbSchemaContainer(); - } - - /** - * called at start-up and when the selected connection profile changes - */ - private void updateReconnectLink() { - this.reconnectLink.setEnabled(this.reconnectLinkCanBeEnabled()); - } - - void updateAddJpaProjectConnectionLink() { - this.addJpaProjectConnectionLink.setEnabled(this.addJpaProjectConnectionLinkCanBeEnabled()); - } - - private boolean reconnectLinkCanBeEnabled() { - if(this.projectHasAConnection()) { - return this.getJpaProjectConnectionProfile().isInactive(); - } - return false; - } - - private boolean addJpaProjectConnectionLinkCanBeEnabled() { - return ! this.projectHasAConnection(); - } - - /** - * the schema combo-box is updated at start-up and - * when the selected connection profile changes - */ - private void updateSchemaComboBox() { - this.schemaComboBox.removeAll(); - for (String name : this.getSchemaNames()) { - this.schemaComboBox.add(name); - } - // the current schema *should* be in the current connection profile - if (this.selectedSchema != null) { - this.schemaComboBox.select(this.schemaComboBox.indexOf(this.selectedSchema.getName())); - } - } - - private Iterable<String> getSchemaNames() { - SchemaContainer sc = this.getDefaultSchemaContainer(); - // use schema *names* since the combo-box is read-only - return (sc != null) ? sc.getSortedSchemaNames() : EmptyIterable.<String>instance(); - } - - // ********** listener callbacks ********** - - void selectedSchemaChanged() { - Schema old = this.selectedSchema; - this.selectedSchema = this.getDefaultSchemaContainer().getSchemaNamed(this.schemaComboBox.getText()); - if (this.selectedSchema != old) { - DatabaseSchemaWizardPage.this.fireSchemaChanged(this.selectedSchema); - } - } - - void reconnect() { - this.getJpaProjectConnectionProfile().connect(); - // everything should be synchronized when we get the resulting open event - } - - /** - * called when - * - a connection is set to the Jpa project - * - the connection was opened - * - the connection was closed (never happens?) - * we need to update the schema stuff and the reconnect link - */ - void connectionChanged() { - Schema old = this.selectedSchema; - this.selectedSchema = this.getDefaultSchema(); - if (this.selectedSchema != old) { - DatabaseSchemaWizardPage.this.fireSchemaChanged(this.selectedSchema); - } - this.updateSchemaComboBox(); - this.updateReconnectLink(); - } - - - // ********** listeners ********** - - private SelectionListener buildSchemaComboBoxSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - // nothing special for "default" (double-click?) - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - DatabaseGroup.this.selectedSchemaChanged(); - } - @Override - public String toString() { - return "DatabaseSchemaWizardPage schema combo-box selection listener"; //$NON-NLS-1$ - } - }; - } - - private SelectionListener buildReconnectLinkSelectionListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - DatabaseGroup.this.reconnect(); - } - @Override - public String toString() { - return "DatabaseSchemaWizardPage reconnect link selection listener"; //$NON-NLS-1$ - } - }; - } - - private ConnectionListener buildConnectionListener() { - return new ConnectionAdapter() { - @Override - public void opened(ConnectionProfile cp) { - this.connectionChanged(); - } - @Override // this probably won't ever get called... - public void closed(ConnectionProfile cp) { - this.connectionChanged(); - } - private void connectionChanged() { - Display.getDefault().asyncExec( - new Runnable() { - public void run() { - DatabaseGroup.this.connectionChanged(); - } - } - ); - } - @Override - public String toString() { - return "DatabaseSchemaWizardPage connection listener"; //$NON-NLS-1$ - } - }; - } - - private SelectionListener buildAddJpaProjectConnectionLinkListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - DatabaseGroup.this.promptToConfigJpaProjectConnection(); - - DatabaseGroup.this.addJpaProjectConnectionListener(); - DatabaseGroup.this.updateAddJpaProjectConnectionLink(); - DatabaseGroup.this.connectionChanged(); - } - @Override - public String toString() { - return "DatabaseSchemaWizardPage AddProjectConnection link selection listener"; //$NON-NLS-1$ - } - }; - } - - void promptToConfigJpaProjectConnection() { - PreferenceDialog dialog = - PreferencesUtil.createPropertyDialogOn( - getShell(), DatabaseSchemaWizardPage.this.jpaProject.getProject(), - JpaProjectPropertiesPage.PROP_ID, - null, - null); - dialog.open(); - } - - // ********** UI components ********** - - /** - * build and return a label - */ - private Label buildLabel(Composite parent, int span, String text) { - Label label = new Label(parent, SWT.NONE); - label.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - label.setLayoutData(gd); - return label; - } - - /** - * build and return a combo-box - */ - private Combo buildComboBox(Composite parent, SelectionListener listener) { - Combo combo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); - combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - combo.addSelectionListener(listener); - return combo; - } - - /** - * build and return a link - */ - private Link buildLink(Composite parent, String text, SelectionListener listener) { - Link link = new Link(parent, SWT.NONE); - GridData data = new GridData(GridData.END, GridData.CENTER, false, false); - data.horizontalSpan = 2; - link.setLayoutData(data); - link.setText(text); - link.addSelectionListener(listener); - return link; - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetActionPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetActionPage.java deleted file mode 100644 index 118c02928a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetActionPage.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 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.jpa.ui.internal.wizards; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -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.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; -import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; -import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage; - -public abstract class JpaFacetActionPage - extends DataModelFacetInstallPage - implements JpaFacetDataModelProperties -{ - protected JpaFacetActionPage(String pageName) { - super(pageName); - setTitle(JptUiMessages.JpaFacetWizardPage_title); - setDescription(JptUiMessages.JpaFacetWizardPage_description); - setImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.JPA_WIZ_BANNER)); - } - - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - - addSubComposites(composite); - - setUpRuntimeListener(); - - Dialog.applyDialogFont(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.DIALOG_JPA_FACET); - - return composite; - } - - protected abstract void addSubComposites(Composite composite); - - private void setUpRuntimeListener() { - final IFacetedProjectWorkingCopy wc = ( (ModifyFacetedProjectWizard) getWizard() ).getFacetedProjectWorkingCopy(); - // must do it manually the first time - model.setProperty(RUNTIME, wc.getPrimaryRuntime()); - wc.addListener( - new IFacetedProjectListener() { - public void handleEvent( final IFacetedProjectEvent event ) { - model.setProperty(RUNTIME, wc.getPrimaryRuntime()); - } - }, - IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED - ); - } - - 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, - CONNECTION, - USER_WANTS_TO_OVERRIDE_DEFAULT_CATALOG, - USER_OVERRIDE_DEFAULT_CATALOG, - USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA, - USER_OVERRIDE_DEFAULT_SCHEMA, - DISCOVER_ANNOTATED_CLASSES, - LIBRARY_PROVIDER_DELEGATE - }; - } - - @Override - public boolean isPageComplete() { - if (! super.isPageComplete()) { - return false; - } - else { - IStatus status = 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(JptUiMessages.JpaFacetWizardPage_platformLabel); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.DIALOG_JPA_PLATFORM); - - platformCombo = createCombo(group, 1, true); - synchHelper.synchCombo(platformCombo, PLATFORM, null); - } - } - - - protected final class ClasspathConfigGroup - { - public ClasspathConfigGroup(Composite composite) { - - final LibraryInstallDelegate librariesInstallDelegate - = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_PROVIDER_DELEGATE); - - final Composite librariesComposite - = (Composite) LibraryProviderFrameworkUi.createInstallLibraryPanel( - composite, librariesInstallDelegate, - JptUiMessages.JpaFacetWizardPage_jpaImplementationLabel ); - librariesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(librariesComposite, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH); - } - } - - - protected final class PersistentClassManagementGroup - { - private final Button discoverClassesButton; - - private final Button listClassesButton; - - - public PersistentClassManagementGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptUiMessages.JpaFacetWizardPage_persistentClassManagementLabel); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH); - - discoverClassesButton = createButton(group, 1, JptUiMessages.JpaFacetWizardPage_discoverClassesButton, SWT.RADIO); - synchHelper.synchRadio(discoverClassesButton, DISCOVER_ANNOTATED_CLASSES, null); - - listClassesButton = createButton(group, 1, JptUiMessages.JpaFacetWizardPage_listClassesButton, SWT.RADIO); - synchHelper.synchRadio(listClassesButton, LIST_ANNOTATED_CLASSES, null); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetInstallPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetInstallPage.java deleted file mode 100644 index e6f4b843ac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetInstallPage.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards; - -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.JptJpaDbPlugin; -import org.eclipse.jpt.jpa.db.ui.internal.DTPUiTools; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -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.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.ui.PlatformUI; - -public class JpaFacetInstallPage - extends JpaFacetActionPage - implements JpaFacetInstallDataModelProperties -{ - public JpaFacetInstallPage() { - super("jpt.jpa.facet.install.page"); //$NON-NLS-1$ - } - - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.NEW_JPA_PROJECT_JPA_FACET); - return composite; - } - - @Override - protected void addSubComposites(Composite composite) { - new PlatformGroup(composite); - new ClasspathConfigGroup(composite); - new ConnectionGroup(composite); - new PersistentClassManagementGroup(composite); - new OrmXmlGroup(composite); - } - - @Override - protected String[] getValidationPropertyNames() { - String[] validationPropertyNames = super.getValidationPropertyNames(); - return ArrayTools.addAll( - validationPropertyNames, - USER_WANTS_TO_ADD_DB_DRIVER_JARS_TO_CLASSPATH, - DB_DRIVER_NAME); - } - - - protected final class ConnectionGroup - { - private final Combo connectionCombo; - - private Link connectionLink; - - private Link connectLink; - - private final Button addDriverLibraryButton; - - private final Label driverLibraryLabel; - - private final Combo driverLibraryCombo; - - private final Button overrideDefaultCatalogButton; - - private final Label defaultCatalogLabel; - - private final Combo defaultCatalogCombo; - - private final Button overrideDefaultSchemaButton; - - private final Label defaultSchemaLabel; - - private final Combo defaultSchemaCombo; - - - public ConnectionGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptUiMessages.JpaFacetWizardPage_connectionLabel); - group.setLayout(new GridLayout(3, false)); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_DATABASE); - - connectionCombo = createCombo(group, 3, true); - synchHelper.synchCombo(connectionCombo, CONNECTION, null); - connectionCombo.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateConnectionStatus(); - } - }); - - connectionLink = new Link(group, SWT.NONE); - GridData data = new GridData(GridData.END, GridData.CENTER, false, false); - data.horizontalSpan = 2; - connectionLink.setLayoutData(data); - connectionLink.setText(JptUiMessages.JpaFacetWizardPage_connectionLink); - connectionLink.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - openNewConnectionWizard(); - } - } - ); - - connectLink = new Link(group, SWT.NONE); - data = new GridData(GridData.END, GridData.CENTER, false, false); - data.horizontalSpan = 2; - connectLink.setLayoutData(data); - connectLink.setText(JptUiMessages.JpaFacetWizardPage_connectLink); - connectLink.setEnabled(false); - connectLink.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - openConnectionProfile(); - } - }); - - addDriverLibraryButton = createButton(group, 3, JptUiMessages.JpaFacetWizardPage_addDriverLibraryLabel, SWT.CHECK); - addDriverLibraryButton.setSelection(false); - synchHelper.synchCheckbox(addDriverLibraryButton, USER_WANTS_TO_ADD_DB_DRIVER_JARS_TO_CLASSPATH, null); - - driverLibraryLabel = new Label(group, SWT.LEFT); - driverLibraryLabel.setText(JptUiMessages.JpaFacetWizardPage_driverLibraryLabel); - GridData gd = new GridData(); - gd.horizontalSpan = 1; - driverLibraryLabel.setLayoutData(gd); - - driverLibraryCombo = createCombo(group, 1, true); - synchHelper.synchCombo( - driverLibraryCombo, DB_DRIVER_NAME, - new Control[] {driverLibraryLabel}); - - overrideDefaultCatalogButton = createButton(group, 3, JptUiMessages.JpaFacetWizardPage_overrideDefaultCatalogLabel, SWT.CHECK); - overrideDefaultCatalogButton.setSelection(false); - synchHelper.synchCheckbox(overrideDefaultCatalogButton, USER_WANTS_TO_OVERRIDE_DEFAULT_CATALOG, null); - - defaultCatalogLabel = new Label(group, SWT.LEFT); - defaultCatalogLabel.setText(JptUiMessages.JpaFacetWizardPage_defaultCatalogLabel); - gd = new GridData(); - gd.horizontalSpan = 1; - defaultCatalogLabel.setLayoutData(gd); - - defaultCatalogCombo = createCombo(group, 1, true); - synchHelper.synchCombo( - defaultCatalogCombo, USER_OVERRIDE_DEFAULT_CATALOG, - new Control[] {defaultCatalogLabel}); - - overrideDefaultSchemaButton = createButton(group, 3, JptUiMessages.JpaFacetWizardPage_overrideDefaultSchemaLabel, SWT.CHECK); - overrideDefaultSchemaButton.setSelection(false); - synchHelper.synchCheckbox(overrideDefaultSchemaButton, USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA, null); - - defaultSchemaLabel = new Label(group, SWT.LEFT); - defaultSchemaLabel.setText(JptUiMessages.JpaFacetWizardPage_defaultSchemaLabel); - gd = new GridData(); - gd.horizontalSpan = 1; - defaultSchemaLabel.setLayoutData(gd); - - defaultSchemaCombo = createCombo(group, 1, true); - synchHelper.synchCombo( - defaultSchemaCombo, USER_OVERRIDE_DEFAULT_SCHEMA, - new Control[] {defaultSchemaLabel}); - } - - private void openNewConnectionWizard() { - String connectionName = DTPUiTools.createNewConnectionProfile(); - if (connectionName != null) { - model.setProperty(CONNECTION, connectionName); - updateConnectionStatus(); - } - } - - private void openConnectionProfile() { - ConnectionProfile cp = getConnectionProfile(); - if (cp != null) { - cp.connect(); - model.setBooleanProperty(CONNECTION_ACTIVE, cp.isActive()); - updateConnectionStatus(); - } - } - - private void updateConnectionStatus() { - ConnectionProfile cp = this.getConnectionProfile(); - updateConnectLink(cp); - addDriverLibraryButton.setEnabled(cp != null); - } - - private ConnectionProfile getConnectionProfile() { - // we just use the connection profile to log in, so go to the the db plug-in - return JptJpaDbPlugin.getConnectionProfileFactory().buildConnectionProfile(model.getStringProperty(CONNECTION)); - } - - private void updateConnectLink(ConnectionProfile cp) { - connectLink.setEnabled((cp != null) && cp.isDisconnected()); - if (cp != null && cp.isConnected()) { - updateConnectLinkText(JptUiMessages.JpaFacetWizardPage_connectedText); - } - else { - updateConnectLinkText(JptUiMessages.JpaFacetWizardPage_connectLink); - } - } - - private void updateConnectLinkText(String text) { - connectLink.setText(text); - SWTUtil.reflow(connectLink.getParent()); - } - } - - - protected final class OrmXmlGroup - { - private final Button createOrmXmlButton; - - - public OrmXmlGroup(Composite composite) { - Composite group = new Composite(composite, SWT.NONE); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.DIALOG_CREATE_ORM); - - createOrmXmlButton = new Button(group, SWT.CHECK); - createOrmXmlButton.setText(JptUiMessages.JpaFacetWizardPage_createOrmXmlButton); - synchHelper.synchCheckbox(createOrmXmlButton, CREATE_ORM_XML, null); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetVersionChangePage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetVersionChangePage.java deleted file mode 100644 index e0c5e8d14a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaFacetVersionChangePage.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.internal.wizards; - -import org.eclipse.swt.widgets.Composite; - -public class JpaFacetVersionChangePage - extends JpaFacetActionPage -{ - public JpaFacetVersionChangePage() { - super("jpt.jpa.facet.version-change.page"); //$NON-NLS-1$ - } - - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - // TODO - //this.getHelpSystem().setHelp(composite, JpaHelpContextIds.NEW_JPA_PROJECT_JPA_FACET); - return composite; - } - - @Override - protected void addSubComposites(Composite composite) { - new PlatformGroup(composite); - new ClasspathConfigGroup(composite); - //new ConnectionGroup(composite); - //new PersistentClassManagementGroup(composite); - } - - @Override - protected String[] getValidationPropertyNames() { - // nothing new here *just* yet - return super.getValidationPropertyNames(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizard.java deleted file mode 100644 index 73c7c2d5e7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizard.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards; - -import java.util.List; -import org.eclipse.jdt.core.IType; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.resource.LocalResourceManager; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; - -public class JpaMakePersistentWizard extends Wizard { - - public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$ - - - final List<IType> selectedTypes; - - private JpaMakePersistentWizardPage makePersistentWizardPage; - - protected final ResourceManager resourceManager; - - public JpaMakePersistentWizard(List<IType> selectedTypes) { - super(); - this.selectedTypes = selectedTypes; - this.resourceManager = new LocalResourceManager(JFaceResources.getResources()); - this.setWindowTitle(JptUiMessages.JpaMakePersistentWizardPage_title); - this.setDefaultPageImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.ENTITY_WIZ_BANNER)); - } - - @Override - public void addPages() { - setForcePreviousAndNextButtons(true); - - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(this.selectedTypes.get(0).getResource().getProject()); - this.makePersistentWizardPage = new JpaMakePersistentWizardPage(jpaProject, this.selectedTypes, HELP_CONTEXT_ID); - this.addPage(this.makePersistentWizardPage); - return; - } - - @Override - public boolean performFinish() { - this.makePersistentWizardPage.performFinish(); - return true; - } - - protected PersistenceUnit getPersistenceUnit(JpaProject jpaProject) { - PersistenceXml persistenceXml = jpaProject.getRootContextNode().getPersistenceXml(); - if (persistenceXml != null) { - Persistence persistence = persistenceXml.getPersistence(); - if (persistence != null && persistence.persistenceUnitsSize() > 0) { - return persistence.persistenceUnits().next(); - } - } - return null; - } - - @Override - public void dispose() { - this.resourceManager.dispose(); - super.dispose(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java deleted file mode 100644 index 10da49bc40..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java +++ /dev/null @@ -1,635 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards; - -import java.io.File; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.ui.JavaElementComparator; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnLabelProvider; -import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -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.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.jpt.jpa.ui.JpaPlatformUi; -import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter; -import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.EntityWizardMsg; -import org.eclipse.jpt.jpa.ui.internal.wizards.orm.MappingFileWizard; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -public class JpaMakePersistentWizardPage extends WizardPage { - - // sizing constants - private final static int TABLE_HEIGHT = 250; - private final static int TABLE_WIDTH = 300; - - private static String MAKE_PERSISTENT_PAGE_NAME = "MakePersistent"; //$NON-NLS-1$ - private TableViewer classTableViewer; - private final String helpContextId; - - private final Type[] selectedTypes; - - private final JpaProject jpaProject; - private JptResourceType jptResourceType; - - private final WritablePropertyValueModel<Boolean> annotateInJavaModel; - - private boolean isFirstCheck = true; - private final WritablePropertyValueModel<String> mappingFileModel; - - private final WritablePropertyValueModel<Boolean> listInPersistenceXmlModel; - - protected JpaMakePersistentWizardPage(final JpaProject jpaProject, final List<IType> selectedTypes, final String helpContextId) { - super(MAKE_PERSISTENT_PAGE_NAME); - this.jpaProject = jpaProject; - - this.selectedTypes = this.buildTypes(selectedTypes); - this.jptResourceType = JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE; - this.helpContextId = helpContextId; - this.annotateInJavaModel = new SimplePropertyValueModel<Boolean>(Boolean.TRUE); - this.mappingFileModel = new SimplePropertyValueModel<String>(); - this.listInPersistenceXmlModel = new SimplePropertyValueModel<Boolean>(Boolean.valueOf(!this.jpaProject.discoversAnnotatedClasses())); - this.setTitle(JptUiMessages.JpaMakePersistentWizardPage_title); - this.setMessage(JptUiMessages.JpaMakePersistentWizardPage_message); - } - - protected Type[] buildTypes(final List<IType> selectedTypes) { - return CollectionTools.list( - new TransformationIterable<IType, Type>(nonPersistentTypes(selectedTypes)) { - @Override - protected Type transform(IType jdtType) { - return new Type(jdtType); - } - }).toArray(new Type[] {}); - } - - /** - * Return all ITypes that are not already persistent. - * Any root structure nodes means the type is already annotated, - * listed in persistence.xml, or listed in a mapping file - */ - protected Iterable<IType> nonPersistentTypes(final List<IType> selectedTypes) { - return new FilteringIterable<IType>(selectedTypes) { - @Override - protected boolean accept(IType jdtType) { - return getJpaProject().getJpaFile((IFile) jdtType.getResource()).rootStructureNodesSize() == 0; - } - }; - } - - protected JpaProject getJpaProject() { - return this.jpaProject; - } - - protected JpaPlatformUi getJpaPlatformUi() { - String platformId = this.getJpaProject().getJpaPlatform().getId(); - return JpaPlatformUiRegistry.instance().getJpaPlatformUi(platformId); - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 1; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - Button javaAnnotationButton = new Button(composite, SWT.RADIO); - javaAnnotationButton.setText(JptUiMessages.JpaMakePersistentWizardPage_annotateInJavaRadioButton); - javaAnnotationButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - JpaMakePersistentWizardPage.this.annotateInJavaModel.setValue(Boolean.TRUE); - JpaMakePersistentWizardPage.this.jptResourceType = JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE; - } - - public void widgetDefaultSelected(SelectionEvent e) { - this.widgetSelected(e); - } - }); - - Button mappingFileButton = new Button(composite, SWT.RADIO); - mappingFileButton.setText(JptUiMessages.JpaMakePersistentWizardPage_mappingFileRadioButton); - Composite mappingFileComposite = this.createMappingFileControl(composite); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.grabExcessHorizontalSpace = true; - mappingFileComposite.setLayoutData(data); - - mappingFileButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - JpaMakePersistentWizardPage.this.annotateInJavaModel.setValue(Boolean.FALSE); - if (JpaMakePersistentWizardPage.this.isFirstCheck) { - JpaMakePersistentWizardPage.this.mappingFileModel.setValue(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString()); - JpaMakePersistentWizardPage.this.isFirstCheck = false; - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - this.widgetSelected(e); - } - }); - - - this.classTableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); - this.classTableViewer.getTable().setLinesVisible(true); - this.classTableViewer.getTable().setHeaderVisible(true); - this.classTableViewer.setContentProvider(new TypeContentProvider()); - this.classTableViewer.setComparator(new TypeComparator()); - this.createTypeTableColumn(); - this.createMappingTableColumn(); - this.classTableViewer.setInput(this.selectedTypes); - - data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.heightHint = TABLE_HEIGHT; - data.widthHint = TABLE_WIDTH; - this.classTableViewer.getTable().setLayoutData(data); - - final Button persistenceXmlCheckBox = new Button(composite, SWT.CHECK); - persistenceXmlCheckBox.setText(JptUiMessages.JpaMakePersistentWizardPage_listInPersistenceXmlCheckBox); - SWTTools.bind(this.listInPersistenceXmlModel, persistenceXmlCheckBox); - SWTTools.controlVisibleState(this.annotateInJavaModel, persistenceXmlCheckBox); - - setControl(composite); - - this.validate(); - } - - private Composite createMappingFileControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.marginLeft = 10; - composite.setLayout(layout); - - Link mappingFileLink = new Link(composite, SWT.LEFT); - mappingFileLink.setText(JptUiMessages.JpaMakePersistentWizardPage_mappingFileLink); - mappingFileLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - mappingFileLink.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - openNewMappingFileWizard(); - } - } - ); - - Text mappingFileText = this.createText(composite, 1); - SWTTools.bind(this.mappingFileModel, mappingFileText); - this.mappingFileModel.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - JpaXmlResource ormXmlResource = getOrmXmlResource(); - if (ormXmlResource == null) { - jptResourceType = JptJpaCorePlugin.ORM_XML_1_0_RESOURCE_TYPE; //just default to 1.0 orm resource type - } - else { - jptResourceType = ormXmlResource.getResourceType(); - } - validate(); - } - }); - - Button browseButton = new Button(composite, SWT.PUSH); - browseButton.setText(JptUiMessages.JpaMakePersistentWizardPage_mappingFileBrowseButton); - browseButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - mappingFileBrowseButtonPressed(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - }); - - SWTTools.controlEnabledState(new ListInOrmMappingFileModel(this.annotateInJavaModel), mappingFileLink, mappingFileText, browseButton); - - return composite; - } - - private Text createText(Composite container, int span) { - Text text = new Text(container, SWT.BORDER | SWT.SINGLE); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = span; - gd.grabExcessHorizontalSpace = true; - text.setLayoutData(gd); - return text; - } - - private void mappingFileBrowseButtonPressed() { - ViewerFilter filter = buildMappingFileDialogViewerFilter(); - ITreeContentProvider contentProvider = new WorkbenchContentProvider(); - ILabelProvider labelProvider = new WorkbenchLabelProvider(); - SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), this.jpaProject.getProject(), labelProvider, contentProvider); - dialog.setTitle(EntityWizardMsg.MAPPING_XML_TITLE); - dialog.setMessage(EntityWizardMsg.CHOOSE_MAPPING_XML_MESSAGE); - dialog.addFilter(filter); - - JpaXmlResource resource = this.jpaProject.getMappingFileXmlResource(new Path(getMappingFileLocation())); - IFile initialSelection = (resource != null) ? resource.getFile() : null; - dialog.setInput(this.jpaProject.getProject()); - - if (initialSelection != null) { - dialog.setInitialSelection(initialSelection); - } - if (dialog.open() == Window.OK) { - this.mappingFileModel.setValue(dialog.getChosenName()); - //have to validate in case the file name did not actually change, but the xml file was created - validate(); - } - } - - /** - * This method create filter for the browse/add alternative mapping XML - * @return new instance of viewer filter for the SelectMappingXMLDialog - */ - protected ViewerFilter buildMappingFileDialogViewerFilter() { - return new XmlMappingFileViewerFilter(this.jpaProject); - } - - private void openNewMappingFileWizard() { - IPath path = MappingFileWizard.createNewMappingFile( - new StructuredSelection(this.jpaProject.getProject()), - getMappingFileName()); - if (path != null) { - this.mappingFileModel.setValue(path.toString()); - //have to validate in case the file name did not actually change, but the xml file was created - this.validate(); - } - } - - protected void createTypeTableColumn() { - TableViewerColumn column = new TableViewerColumn(this.classTableViewer, SWT.NONE); - column.getColumn().setWidth(200); - column.getColumn().setText(JptUiMessages.JpaMakePersistentWizardPage_typeTableColumn); - column.setLabelProvider(this.buildTypeColumnLabelProvider()); - } - - protected ColumnLabelProvider buildTypeColumnLabelProvider() { - return new TypeColumnLabelProvider(); - } - - protected void createMappingTableColumn() { - TableViewerColumn column; - column = new TableViewerColumn(this.classTableViewer, SWT.NONE); - column.getColumn().setWidth(200); - column.getColumn().setText(JptUiMessages.JpaMakePersistentWizardPage_mappingTableColumn); - - column.setEditingSupport(new EditingSupport(this.classTableViewer) { - @Override - protected Object getValue(Object element) { - return getMappingUiDefinition(((Type) element).mappingKey); - } - - @Override - protected void setValue(Object element, Object value) { - ((Type) element).setMappingKey(((MappingUiDefinition<?, ?>) value).getKey()); - getViewer().update(element, null); - } - - @Override - protected CellEditor getCellEditor(Object element) { - final ComboBoxViewerCellEditor comboCellEditor = - new ComboBoxViewerCellEditor((Composite) JpaMakePersistentWizardPage.this.classTableViewer.getControl()); - - comboCellEditor.setLabelProvider(buildMappingComboCellEditorLabelProvider()); - comboCellEditor.setContentProvider(buildMappingComboCellEditorContentProvider()); - comboCellEditor.setInput(element); - return comboCellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - }); - - column.setLabelProvider(buildMappingColumnLabelProvider()); - } - - //The ComboBoxViewerCellEditor does not support the image, so no reason to implement getImage(Object) - protected ColumnLabelProvider buildMappingComboCellEditorLabelProvider() { - return new ColumnLabelProvider() { - @Override - public String getText(Object element) { - return ((MappingUiDefinition<?, ?>) element).getLabel(); - } - }; - } - - protected IStructuredContentProvider buildMappingComboCellEditorContentProvider() { - return new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - return CollectionTools.collection(((Type) inputElement).typeMappingUiDefinitions()).toArray(); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } - - public void dispose() { - //do nothing - } - }; - } - - protected ColumnLabelProvider buildMappingColumnLabelProvider() { - return new ColumnLabelProvider() { - @Override - public String getText(Object element) { - MappingUiDefinition<? extends PersistentType, ?> mappingUiDefinition = getMappingUiDefinition(((Type) element).mappingKey); - return mappingUiDefinition.getLabel(); - } - - @Override - public Image getImage(Object element) { - MappingUiDefinition<? extends PersistentType, ?> mappingUiDefinition = getMappingUiDefinition(((Type) element).mappingKey); - return mappingUiDefinition.getImage(); - } - }; - } - - protected MappingUiDefinition<? extends PersistentType, ?> getMappingUiDefinition(String mappingKey) { - for (MappingUiDefinition<? extends PersistentType, ?> provider : typeMappingUiDefinitions(this.jptResourceType)) { - if (provider.getKey() == mappingKey) { - return provider; - } - } - throw new IllegalArgumentException(); - } - - protected Iterable<String> typeMappingKeys(Iterable<? extends MappingUiDefinition<? extends PersistentType, ?>> mappingUiDefinitions) { - return new TransformationIterable<MappingUiDefinition<? extends PersistentType, ?>, String>(mappingUiDefinitions) { - @Override - protected String transform(MappingUiDefinition<? extends PersistentType, ?> next) { - return next.getKey(); - } - }; - } - - protected Iterable<? extends MappingUiDefinition<? extends PersistentType, ?>> typeMappingUiDefinitions(JptResourceType jpaResourceType) { - return CollectionTools.iterable(getJpaPlatformUi().typeMappingUiDefinitions(jpaResourceType)); - } - - protected void validate() { - String errorMessage = null; - if (this.selectedTypes.length == 0) { - errorMessage = JptUiMessages.JpaMakePersistentWizardPage_selectedTypesPersistentError; - } - else if (this.isAddToOrmMappingFile()) { - JpaXmlResource ormXmlResource = getOrmXmlResource(); - if (ormXmlResource == null) { - errorMessage = JptUiMessages.JpaMakePersistentWizardPage_mappingFileDoesNotExistError; - } - else if (getJpaProject().getJpaFile(ormXmlResource.getFile()).rootStructureNodesSize() == 0) { - errorMessage = JptUiMessages.JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError; - } - } - setErrorMessage(errorMessage); - setPageComplete(errorMessage == null); - } - - @Override - public final void performHelp() { - PlatformUI.getWorkbench().getHelpSystem().displayHelp( this.helpContextId ); - } - - protected void performFinish() { - boolean modifiedPersistenceXml = false; - for (Type type : this.selectedTypes) { - modifiedPersistenceXml |= type.makePersistent(); - } - if (modifiedPersistenceXml) { - try { - this.getJpaProject().getPersistenceXmlResource().save(null); - } - catch (IOException e) { - //ignore, file just won't get saved - } - } - } - - protected JpaXmlResource getOrmXmlResource() { - return getJpaProject().getMappingFileXmlResource(new Path(getMappingFileLocation())); - } - - protected EntityMappings getEntityMappings() { - JpaXmlResource xmlResource = getOrmXmlResource(); - return (EntityMappings) getJpaProject().getJpaFile(xmlResource.getFile()).rootStructureNodes().next(); - } - - protected boolean isListInPersistenceXml() { - return this.listInPersistenceXmlModel.getValue().booleanValue(); - } - - protected boolean isAnnotateInJavaModel() { - return this.annotateInJavaModel.getValue().booleanValue(); - } - - protected boolean isAddToOrmMappingFile() { - return !isAnnotateInJavaModel(); - } - - protected String getMappingFileLocation() { - return this.mappingFileModel.getValue(); - } - - protected String getMappingFileName() { - return new File(getMappingFileLocation()).getName(); - } - - private class Type { - - private final IType jdtType; - - private String mappingKey; - - protected Type(IType jdtType) { - super(); - this.jdtType = jdtType; - this.mappingKey = MappingKeys.ENTITY_TYPE_MAPPING_KEY; - } - - protected void setMappingKey(String mappingKey) { - this.mappingKey = mappingKey; - } - - protected boolean makePersistent() { - if (JpaMakePersistentWizardPage.this.isAnnotateInJavaModel()) { - PersistenceUnit persistenceUnit = this.getPersistenceUnit(); - JavaResourcePersistentType persistentType = getJavaResourcePersistentType(); - persistentType.addAnnotation(getJavaTypeMappingDefinition(this.mappingKey).getAnnotationName()); - if (JpaMakePersistentWizardPage.this.isListInPersistenceXml()) { - if (persistenceUnit != null) { - persistenceUnit.addSpecifiedClassRef(persistentType.getQualifiedName()); - return true; - } - } - } - else { - JpaXmlResource ormXmlResource = getOrmXmlResource(); - final EntityMappings entityMappings = getEntityMappings(); - ormXmlResource.modify(new Runnable() { - public void run() { - entityMappings.addPersistentType(Type.this.mappingKey, Type.this.jdtType.getFullyQualifiedName()); - } - }); - } - return false; - } - - protected Iterable<? extends MappingUiDefinition<? extends PersistentType, ?>> typeMappingUiDefinitions() { - return CollectionTools.iterable(getJpaPlatformUi().typeMappingUiDefinitions(jptResourceType)); - } - - protected JavaTypeMappingDefinition getJavaTypeMappingDefinition(String key) { - for (JavaTypeMappingDefinition definition : getJpaProject().getJpaPlatform().getJavaTypeMappingDefinitions()) { - if (Tools.valuesAreEqual(definition.getKey(), key)) { - return definition; - } - } - throw new IllegalArgumentException("Illegal type mapping key: " + key); //$NON-NLS-1$ - } - - protected JavaResourcePersistentType getJavaResourcePersistentType() { - return getJpaProject().getJavaResourcePersistentType(this.jdtType.getFullyQualifiedName()); - } - - - protected PersistenceUnit getPersistenceUnit() { - Persistence p = this.getPersistence(); - if (p == null) { - return null; - } - Iterator<PersistenceUnit> units = p.persistenceUnits(); - return units.hasNext() ? units.next() : null; - } - - protected Persistence getPersistence() { - PersistenceXml pxml = this.getPersistenceXml(); - return (pxml == null) ? null : pxml.getPersistence(); - } - - protected PersistenceXml getPersistenceXml() { - JpaRootContextNode rcn = getJpaProject().getRootContextNode(); - return (rcn == null) ? null : rcn.getPersistenceXml(); - } - } - - private final class TypeContentProvider implements IStructuredContentProvider - { - public Object[] getElements(Object inputElement){ - return (Type[]) inputElement; - } - - public void dispose(){} - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput){} - - } - - private final class TypeColumnLabelProvider extends ColumnLabelProvider - { - private final JavaElementLabelProvider javaElementLabelProvider = - new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_POST_QUALIFIED - | JavaElementLabelProvider.SHOW_SMALL_ICONS - | JavaElementLabelProvider.SHOW_OVERLAY_ICONS); - - @Override - public String getText(Object element) { - return this.javaElementLabelProvider.getText(((Type) element).jdtType); - } - - @Override - public Image getImage(Object element) { - return this.javaElementLabelProvider.getImage(((Type) element).jdtType); - } - } - - private final class TypeComparator extends ViewerComparator { - private final JavaElementComparator javaElementComparator = new JavaElementComparator(); - - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - return this.javaElementComparator.compare(viewer, ((Type) e1).jdtType, ((Type) e2).jdtType); - } - } - - static class ListInOrmMappingFileModel - extends AspectPropertyValueModelAdapter<Boolean, Boolean> - { - ListInOrmMappingFileModel(PropertyValueModel<Boolean> annotateInJavaModel) { - super(annotateInJavaModel); - } - - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(!this.subject.booleanValue()); - } - - @Override - protected void engageSubject_() {/*nothing*/} - @Override - protected void disengageSubject_() {/*nothing*/} - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/NewEntityDropDownAction.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/NewEntityDropDownAction.java deleted file mode 100644 index dc5484761d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/NewEntityDropDownAction.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - * Oracle - copied and modified from NewJavaEEDropDownAction and NewTypeDropDownAction - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards; - -import java.util.ArrayList; -import java.util.Arrays; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; - -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import org.eclipse.jdt.ui.actions.AbstractOpenWizardAction; -import org.eclipse.jdt.internal.ui.util.CoreUtility; - - -/** - * A type wizard is added to the type drop down if it has a paramater 'javatype': - * <wizard - * name="My JPT Wizard" - * icon="icons/wiz.gif" - * category="mycategory" - * id="xx.MyWizard"> - * <class class="org.xx.MyWizard"> - * <parameter name="jptartifact" value="true"/> - * </class> - * <description> - * My JPT Wizard - * </description> - * </wizard> - */ -public class NewEntityDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 { - - public static class OpenJptWizardAction extends AbstractOpenWizardAction implements Comparable<Object> { - - private final static String ATT_NAME = "name";//$NON-NLS-1$ - private final static String ATT_CLASS = "class";//$NON-NLS-1$ - private final static String ATT_ICON = "icon";//$NON-NLS-1$ - private static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$ - - private IConfigurationElement fConfigurationElement; - private int menuIndex; - - public OpenJptWizardAction(IConfigurationElement element) { - this.fConfigurationElement= element; - setText(element.getAttribute(ATT_NAME)); - - String description= getDescriptionFromConfig(this.fConfigurationElement); - setDescription(description); - setToolTipText(description); - setImageDescriptor(getIconFromConfig(this.fConfigurationElement)); - setMenuIndex(getMenuIndexFromConfig(this.fConfigurationElement)); - } - - private String getDescriptionFromConfig(IConfigurationElement config) { - IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION); - if (children.length>=1) { - return children[0].getValue(); - } - return ""; //$NON-NLS-1$ - } - - private ImageDescriptor getIconFromConfig(IConfigurationElement config) { - String iconName = config.getAttribute(ATT_ICON); - if (iconName != null) { - return AbstractUIPlugin.imageDescriptorFromPlugin(config.getContributor().getName(), iconName); - } - return null; - } - - private int getMenuIndexFromConfig(IConfigurationElement config) { - IConfigurationElement[] classElements = config.getChildren(TAG_CLASS); - if (classElements.length > 0) { - for (IConfigurationElement classElement : classElements) { - IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER); - for (IConfigurationElement paramElement : paramElements) { - if (ATT_MENUINDEX.equals(paramElement.getAttribute(TAG_NAME))) { - return Integer.parseInt(paramElement.getAttribute(TAG_VALUE)); - } - } - } - } - return Integer.MAX_VALUE; - } - - @Override - public void run() { - Shell shell = getShell(); - try { - INewWizard wizard = createWizard(); - wizard.init(PlatformUI.getWorkbench(), getSelection()); - - WizardDialog dialog = new WizardDialog(shell, wizard); - PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); - dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); - dialog.create(); - int res = dialog.open(); - - notifyResult(res == Window.OK); - } catch (CoreException e) { - JptJpaUiPlugin.log(e); - } - } - - @Override - protected INewWizard createWizard() throws CoreException { - return (INewWizard) CoreUtility.createExtension(fConfigurationElement, ATT_CLASS); - } - - public int getMenuIndex() { - return this.menuIndex; - } - - public void setMenuIndex(int menuIndex) { - this.menuIndex = menuIndex; - } - - public int compareTo(Object o) { - OpenJptWizardAction action = (OpenJptWizardAction) o; - return getMenuIndex() - action.getMenuIndex(); - } - - } - - - - private final static String TAG_WIZARD = "wizard";//$NON-NLS-1$ - private final static String ATT_JPTARTIFACT = "jptartifact";//$NON-NLS-1$ - - private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$ - private final static String TAG_NAME = "name";//$NON-NLS-1$ - private final static String TAG_VALUE = "value";//$NON-NLS-1$ - protected final static String ATT_MENUINDEX = "menuIndex";//$NON-NLS-1$ - - private static final String PL_NEW = "newWizards"; //$NON-NLS-1$ - private static final String TAG_CLASS = "class"; //$NON-NLS-1$ - - private Menu fMenu; - - private Shell fWizardShell; - - public NewEntityDropDownAction() { - this.fMenu= null; - setMenuCreator(this); - //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION); - } - - public void dispose() { - if (this.fMenu != null) { - this.fMenu.dispose(); - this.fMenu= null; - } - } - - public Menu getMenu(Menu parent) { - return null; - } - - public Menu getMenu(Control parent) { - if (this.fMenu == null) { - this.fMenu = new Menu(parent); - OpenJptWizardAction[] actions = getActionFromDescriptors(); - for (int i = 0; i < actions.length; i++) { - OpenJptWizardAction curr = actions[i]; - curr.setShell(this.fWizardShell); - ActionContributionItem item = new ActionContributionItem(curr); - item.fill(this.fMenu, -1); - } - - } - return this.fMenu; - } - - @Override - public void run() { - getDefaultAction().run(); - } - - public Action getDefaultAction() { - Action[] actions = getActionFromDescriptors(); - if (actions.length > 0) - return actions[0]; - return null; - } - - public static OpenJptWizardAction[] getActionFromDescriptors() { - ArrayList<OpenJptWizardAction> containers= new ArrayList<OpenJptWizardAction>(); - - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, PL_NEW); - if (extensionPoint != null) { - IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (element.getName().equals(TAG_WIZARD) && isJptArtifactWizard(element)) { - containers.add(new OpenJptWizardAction(element)); - } - } - } - OpenJptWizardAction[] actions = containers.toArray(new OpenJptWizardAction[containers.size()]); - Arrays.sort(actions); - return actions; - } - - private static boolean isJptArtifactWizard(IConfigurationElement element) { - IConfigurationElement[] classElements= element.getChildren(TAG_CLASS); - if (classElements.length > 0) { - for (int i= 0; i < classElements.length; i++) { - IConfigurationElement[] paramElements= classElements[i].getChildren(TAG_PARAMETER); - for (int k = 0; k < paramElements.length; k++) { - IConfigurationElement curr= paramElements[k]; - if (ATT_JPTARTIFACT.equals(curr.getAttribute(TAG_NAME))) { - return Boolean.valueOf(curr.getAttribute(TAG_VALUE)).booleanValue(); - } - } - } - } - return false; - } - - public void init(IWorkbenchWindow window) { - fWizardShell= window.getShell(); - } - - public void run(IAction action) { - run(); - } - - public void selectionChanged(IAction action, ISelection selection) { - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java deleted file mode 100644 index 244078cbb5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards; - -import java.io.File; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.wizards.orm.MappingFileWizard; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; - -public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog -{ - private static final String META_INF = "META-INF";//$NON-NLS-1$ - private static final String EMPTY = "";//$NON-NLS-1$ - private static final char SLASH = '/'; - - private String xmlName = EMPTY; - - private final IProject project; - - private Label messageLabel; - private Tree treeWidget; - - public SelectJpaOrmMappingFileDialog(Shell parent, IProject project, ILabelProvider labelProvider, ITreeContentProvider contentProvider) { - super(parent, labelProvider, contentProvider); - setAllowMultiple(false); - this.project = project; - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - Button newButton = new Button(composite, SWT.PUSH); - newButton.setText(JptUiMessages.SelectJpaOrmMappingFileDialog_newButton); - GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_END); - newButton.setLayoutData(browseButtonData); - newButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - openNewMappingFileWizard(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - return composite; - } - - @Override - protected Label createMessageArea(Composite composite) { - this.messageLabel = super.createMessageArea(composite); - return this.messageLabel; - } - - @Override - protected TreeViewer createTreeViewer(Composite parent) { - TreeViewer treeViewer = super.createTreeViewer(parent); - this.treeWidget = treeViewer.getTree(); - return treeViewer; - } - /** - * @return the name of the alternative mapping XML - */ - public String getChosenName() { - String result = EMPTY; - Object element = getFirstResult(); - if (element instanceof IContainer) { - IContainer container = (IContainer) element; - result = container.getFullPath().toString() + File.separatorChar + this.xmlName; - } else { - IFile f = (IFile) element; - result = f.getFullPath().toOSString(); - } - result = removeRedundantSegmentFromName(result); - return result; - } - - @Override - /* - * @see ElementTreeSelectionDialog#updateOKStatus(Composite) - */ - protected void updateOKStatus() { - super.updateOKStatus(); - TreeSelection selection = (TreeSelection)getTreeViewer().getSelection(); - IResource selectedResource = (IResource) selection.getFirstElement(); - if (selectedResource instanceof IFile) { - updateStatus(new Status(IStatus.OK, JptJpaUiPlugin.PLUGIN_ID, "")); - } - else { - updateStatus(new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, "")); - } - } - - /** - * This method is for internal purposes only - * @param input non formated path to the mapping XML - * @return the formated path to the mapping XML - */ - private String removeRedundantSegmentFromName(String input) { - String output = input.substring(input.indexOf(META_INF)); - output = output.replace(File.separatorChar, SLASH); - return output; - } - - - private void openNewMappingFileWizard() { - IPath path = MappingFileWizard.createNewMappingFile(new StructuredSelection(this.project), null); - if (path != null) { - //these are disabled if the tree is empty when the dialog is created. - this.messageLabel.setEnabled(true); - this.treeWidget.setEnabled(true); - IFile file = JptCommonCorePlugin.getPlatformFile(this.project, path); - getTreeViewer().setSelection(new StructuredSelection(file), true); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/AnnotatedEntityTemplate.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/AnnotatedEntityTemplate.java deleted file mode 100644 index a0c819c4af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/AnnotatedEntityTemplate.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.*; -import java.util.*; - -public class AnnotatedEntityTemplate -{ - protected static String nl; - public static synchronized AnnotatedEntityTemplate create(String lineSeparator) - { - nl = lineSeparator; - AnnotatedEntityTemplate result = new AnnotatedEntityTemplate(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package "; - protected final String TEXT_2 = ";"; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL + "import "; - protected final String TEXT_5 = ";"; - protected final String TEXT_6 = NL + NL + "/**" + NL + " * Entity implementation class for Entity: "; - protected final String TEXT_7 = NL + " *" + NL + " */"; - protected final String TEXT_8 = NL; - protected final String TEXT_9 = "(name=\""; - protected final String TEXT_10 = "\")"; - protected final String TEXT_11 = NL + "@Table(name=\""; - protected final String TEXT_12 = "\")"; - protected final String TEXT_13 = NL; - protected final String TEXT_14 = NL + "@IdClass("; - protected final String TEXT_15 = ".class)"; - protected final String TEXT_16 = NL + "public class "; - protected final String TEXT_17 = " extends "; - protected final String TEXT_18 = " implements "; - protected final String TEXT_19 = ", "; - protected final String TEXT_20 = " {" + NL + "" + NL + "\t"; - protected final String TEXT_21 = " " + NL + "\t@Id"; - protected final String TEXT_22 = NL + "\tprivate "; - protected final String TEXT_23 = " "; - protected final String TEXT_24 = ";"; - protected final String TEXT_25 = NL + "\tprivate static final long serialVersionUID = 1L;" + NL + "" + NL + "\tpublic "; - protected final String TEXT_26 = "() {" + NL + "\t\tsuper();" + NL + "\t}"; - protected final String TEXT_27 = " " + NL + "\t@Id "; - protected final String TEXT_28 = " " + NL + "\tpublic "; - protected final String TEXT_29 = " get"; - protected final String TEXT_30 = "() {" + NL + "\t\treturn this."; - protected final String TEXT_31 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void set"; - protected final String TEXT_32 = "("; - protected final String TEXT_33 = " "; - protected final String TEXT_34 = ") {" + NL + "\t\tthis."; - protected final String TEXT_35 = " = "; - protected final String TEXT_36 = ";" + NL + "\t}"; - protected final String TEXT_37 = NL + " " + NL + "}"; - protected final String TEXT_38 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - CreateEntityTemplateModel model = (CreateEntityTemplateModel) argument; -if (model.getJavaPackageName()!=null && model.getJavaPackageName()!="") { - stringBuffer.append(TEXT_1); - stringBuffer.append(model.getJavaPackageName()); - stringBuffer.append(TEXT_2); - } - stringBuffer.append(TEXT_3); - Collection<String> imports = model.getImports(false); -for (String anImport : imports) { - stringBuffer.append(TEXT_4); - stringBuffer.append(anImport); - stringBuffer.append(TEXT_5); - } - stringBuffer.append(TEXT_6); - stringBuffer.append(model.getEntityName()); - stringBuffer.append(TEXT_7); - stringBuffer.append(TEXT_8); - stringBuffer.append(model.getArtifactType()); - String ENTITY_NAME = model.getEntityName(); -if (model.isEntityNameSet()) { - stringBuffer.append(TEXT_9); - stringBuffer.append(ENTITY_NAME); - stringBuffer.append(TEXT_10); - } - if (model.isTableNameSet()) { - stringBuffer.append(TEXT_11); - stringBuffer.append(model.getTableName()); - stringBuffer.append(TEXT_12); - } - stringBuffer.append(TEXT_13); - stringBuffer.append(model.getInheritanceStrategy()); - if (model.isCompositePK()) { - stringBuffer.append(TEXT_14); - stringBuffer.append(model.getIdClassName()); - stringBuffer.append(TEXT_15); - } - stringBuffer.append(TEXT_16); - stringBuffer.append(model.getClassName()); - String superClass = model.getSuperclassName(); - if (! "".equals(superClass)) { - stringBuffer.append(TEXT_17); - stringBuffer.append(superClass); - } - - List<String> interfaces = model.getInterfaces(); - if (interfaces.size()>0) { - stringBuffer.append(TEXT_18); - } - for (int i=0; i<interfaces.size(); i++) { - String INTERFACE = (String) interfaces.get(i); - if (i>0) { - stringBuffer.append(TEXT_19); - } - stringBuffer.append(INTERFACE); - } - stringBuffer.append(TEXT_20); - List<EntityRow> fields = model.getEntityFields(); - List<String> pkFields = model.getPKFields(); - for (EntityRow entity : fields) { - String NAME = entity.getName(); - if (pkFields.contains(NAME) && model.isFieldAccess()) { - - stringBuffer.append(TEXT_21); - } - stringBuffer.append(TEXT_22); - stringBuffer.append(entity.getType()); - stringBuffer.append(TEXT_23); - stringBuffer.append(entity.getName()); - stringBuffer.append(TEXT_24); - } - stringBuffer.append(TEXT_25); - stringBuffer.append(model.getClassName()); - stringBuffer.append(TEXT_26); - - fields = model.getEntityFields(); - if (fields != null) for (int i=0; i<fields.size(); i++) { - EntityRow field = (EntityRow) fields.get(i); - String TYPE = field.getType(); - String NAME = field.getName(); - String METHOD = NAME.substring(0,1).toUpperCase() + NAME.substring(1); - if (pkFields.contains(NAME) && !model.isFieldAccess()) { - - stringBuffer.append(TEXT_27); - } - stringBuffer.append(TEXT_28); - stringBuffer.append(TYPE); - stringBuffer.append(TEXT_29); - stringBuffer.append(METHOD); - stringBuffer.append(TEXT_30); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_31); - stringBuffer.append(METHOD); - stringBuffer.append(TEXT_32); - stringBuffer.append(TYPE); - stringBuffer.append(TEXT_33); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_34); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_35); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_36); - } - stringBuffer.append(TEXT_37); - stringBuffer.append(TEXT_38); - return stringBuffer.toString(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java deleted file mode 100644 index 2e1b9e5407..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java +++ /dev/null @@ -1,408 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import java.io.File; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter; -import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.IEntityDataModelProperties; -import org.eclipse.jpt.jpa.ui.internal.wizards.orm.MappingFileWizard; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.wizard.NewJavaClassWizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.swt.widgets.Link; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class EntityClassWizardPage - extends NewJavaClassWizardPage { - - private static final String EMPTY = "";//$NON-NLS-1$ - - private static final String SINGLE_TABLE = "SINGLE_TABLE";//$NON-NLS-1$ - private static final String TABLE_PER_CLASS = "TABLE_PER_CLASS";//$NON-NLS-1$ - private static final String JOINED = "JOINED";//$NON-NLS-1$ - private static final String[] INHERITANCE_STRATEGIES = - new String[] {EMPTY, SINGLE_TABLE, TABLE_PER_CLASS, JOINED }; - private Combo inheritanceStrategyCombo; - private Button entityButton; - private Button mapedAsSuperclassButton; - private Button inheritanceButton; - private Link displayNameLink; - private Button xmlSupportButton; - private boolean isFirstCheck = true; - private Text ormXmlName; - private Button browseButton; - - - public EntityClassWizardPage( - IDataModel model, String pageName, String pageDesc, String pageTitle) { - - super(model, pageName, pageDesc, pageTitle, null); - } - - - @Override - protected String[] getValidationPropertyNames() { - return ArrayTools.addAll( - super.getValidationPropertyNames(), - new String[] {IEntityDataModelProperties.XML_NAME, IEntityDataModelProperties.XML_SUPPORT}); - } - - private IProject getProject() { - return (IProject) getDataModel().getProperty(INewJavaClassDataModelProperties.PROJECT); - } - - /* Create top level composite (class properties) and add the entity's specific inheritance group - * @see org.eclipse.jst.j2ee.internal.wizard.NewJavaClassWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.NEW_JPA_ENTITY_ENTITY_CLASS); - - createInheritanceControl(composite); - this.inheritanceButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean isChecked = inheritanceButton.getSelection(); - if (isChecked) { - entityButton.setSelection(true); - mapedAsSuperclassButton.setSelection(false); - } - inheritanceStrategyCombo.setEnabled(isChecked); - model.setBooleanProperty(IEntityDataModelProperties.ENTITY, true); - model.setBooleanProperty(IEntityDataModelProperties.MAPPED_AS_SUPERCLASS, false); - entityButton.setEnabled(!isChecked); - mapedAsSuperclassButton.setEnabled(!isChecked); - } - }); - createXMLstorageControl(composite); - this.xmlSupportButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean isChecked = xmlSupportButton.getSelection(); - enableMappingXMLChooseGroup(isChecked); - if (isFirstCheck) { - ormXmlName.setText(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString()); - isFirstCheck = false; - } - } - }); - return composite; - } - - @Override - protected ISelectionStatusValidator getContainerDialogSelectionValidator() { - return new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - if (selection != null && selection[0] != null) { - if (selection[0] instanceof IProject) { - IProject project = (IProject) selection[0]; - IJavaProject javaProject = JavaCore.create(project); - for (IPackageFragmentRoot root : JDTTools.getJavaSourceFolders(javaProject)) { - if (project.equals(root.getResource())) { - return WTPCommonPlugin.OK_STATUS; - } - } - } - else { - return WTPCommonPlugin.OK_STATUS; - } - } - return WTPCommonPlugin.createErrorStatus(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG); - } - }; - } - - @Override - protected ViewerFilter getContainerDialogViewerFilter() { - return new ViewerFilter() { - @Override - public boolean select(Viewer viewer, Object parent, Object element) { - String projectName = (String) model.getProperty(IEntityDataModelProperties.PROJECT_NAME); - if (element instanceof IProject) { - IProject project = (IProject) element; - return project.getName().equals(projectName); - } - else if (element instanceof IFolder) { - IFolder folder = (IFolder) element; - // only show source folders - IProject project = ProjectUtilities.getProject(projectName); - IJavaProject javaProject = JavaCore.create(project); - for (IPackageFragmentRoot root : JDTTools.getJavaSourceFolders(javaProject)) { - if (folder.equals(root.getResource())) - return true; - } - } - return false; - } - }; - } - - /** - * Create the inheritance group - * @param parent the main composite - */ - private void createInheritanceControl(Composite parent) { - Group group = createGroup(parent, EntityWizardMsg.INHERITANCE_GROUP); - this.entityButton = createRadioButton(group, EntityWizardMsg.ENTITY, IEntityDataModelProperties.ENTITY); - this.mapedAsSuperclassButton = createRadioButton(group, EntityWizardMsg.MAPPED_AS_SUPERCLASS, IEntityDataModelProperties.MAPPED_AS_SUPERCLASS); - this.inheritanceButton = createCheckButton(group, GridData.HORIZONTAL_ALIGN_FILL, 1/*horizontal span*/, EntityWizardMsg.INHERITANCE_CHECK_BOX, IEntityDataModelProperties.INHERITANCE); - createComboBox(group, IEntityDataModelProperties.INHERITANCE_STRATEGY); - } - - /** - * Create the group, which manage entity mapping registration - * @param parent the main composite - */ - private void createXMLstorageControl(Composite parent) { - Group group = createGroup(parent, EntityWizardMsg.XML_STORAGE_GROUP); - this.xmlSupportButton = createCheckButton(group, GridData.FILL_HORIZONTAL, 3/*horizontal span*/, EntityWizardMsg.XML_SUPPORT, IEntityDataModelProperties.XML_SUPPORT); - createBrowseGroup(group, EntityWizardMsg.CHOOSE_XML, IEntityDataModelProperties.XML_NAME); - this.ormXmlName.setEnabled(false); - this.browseButton.setEnabled(false); - } - - /** - * @param parent the main composite - * @param text the name/title of the group - * @return the created group - */ - private Group createGroup(Composite parent, String text) { - Group group = new Group(parent, SWT.NONE); - GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL); - groupGridData.horizontalSpan = 3; - group.setLayoutData(groupGridData); - group.setLayout(new GridLayout(3, false)); - group.setText(text); - return group; - } - - /** - * Create radio button - * @param parent the main composite - inheritance group - * @param text the label of the button - * @param property the related property to which this button will be synchronized - * @return the created button - */ - private Button createRadioButton(Composite parent, String text, String property) { - Button button = new Button(parent, SWT.RADIO); - GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL); - groupGridData.horizontalSpan = 3; - button.setLayoutData(groupGridData); - button.setText(text); - this.synchHelper.synchRadio(button, property, /*dependentControls*/ null); - return button; - } - - /** - * Create check button - * @param parent the main composite - inheritance group - * @param text the label of the button - * @param property the related property to which this button will be synchronized - * @return the created button - */ - private Button createCheckButton(Composite parent, int fillStrategy, int horizontalSpan, String text, String property) { - final Button button = new Button(parent, SWT.CHECK); - GridData groupGridData = new GridData(fillStrategy); - groupGridData.horizontalSpan = horizontalSpan; - button.setLayoutData(groupGridData); - button.setText(text); - this.synchHelper.synchCheckbox(button, property, /*dependentControls*/ null); - return button; - } - - /** - * Create combo box, which presents the set of possible inheritance strategies - * @param parent the main composite - inheritance group - * @param property the related property to which this button will be synchronized - * @return - */ - private Combo createComboBox(Composite parent, String property) { - this.inheritanceStrategyCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); - GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL); - groupGridData.horizontalSpan = 2; - this.inheritanceStrategyCombo.setLayoutData(groupGridData); - this.inheritanceStrategyCombo.setItems(INHERITANCE_STRATEGIES); - this.synchHelper.synchCombo(this.inheritanceStrategyCombo, property, /*dependentControls*/ null); - this.inheritanceStrategyCombo.setEnabled(false); - return this.inheritanceStrategyCombo; - - } - - /** - * Create XML group - * @param parent the main composite - * @param label the name of the group - * @param property the related property to which this group will be synchronized - * @return the created group - */ - private void createBrowseGroup(Composite parent, String label, String property) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(3, false)); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - this.displayNameLink = new Link(composite, SWT.LEFT); - this.displayNameLink.setText(label); - this.displayNameLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - this.displayNameLink.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - openNewMappingFileWizard(); - } - } - ); - - this.ormXmlName = new Text(composite, SWT.SINGLE | SWT.BORDER); - this.ormXmlName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - this.browseButton = new Button(composite, SWT.PUSH); - this.browseButton.setText(EntityWizardMsg.BROWSE_BUTTON_LABEL); - GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - browseButtonData.horizontalSpan = 1; - this.browseButton.setLayoutData(browseButtonData); - this.browseButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - handleChooseXmlButtonPressed(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - this.synchHelper.synchText(this.ormXmlName, property, /*dependentControls*/null); - - enableMappingXMLChooseGroup(false); - } - - private void openNewMappingFileWizard() { - IProject project = getProject(); - IPath path = MappingFileWizard.createNewMappingFile(new StructuredSelection(project), getMappingFileName()); - if (path != null) { - this.model.setProperty(IEntityDataModelProperties.XML_NAME, path.toString()); - //have to validate in case the file name did not actually change, but the xml file was created - validatePage(); - } - } - - protected String getMappingFileName() { - String mappingFileLocation = this.model.getStringProperty(IEntityDataModelProperties.XML_NAME); - return new File(mappingFileLocation).getName(); - } - - /** - * Process browsing when the Browse... button have been pressed. Allow choosing of - * XML for entity mapping registration - * - */ - private void handleChooseXmlButtonPressed() { - IProject project = getProject(); - if (project == null) { - return; - } - JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project); - ViewerFilter filter = getDialogViewerFilter(jpaProject); - ITreeContentProvider contentProvider = new WorkbenchContentProvider(); - ILabelProvider labelProvider = new WorkbenchLabelProvider(); - SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), project, labelProvider, contentProvider); - dialog.setTitle(EntityWizardMsg.MAPPING_XML_TITLE); - dialog.setMessage(EntityWizardMsg.CHOOSE_MAPPING_XML_MESSAGE); - dialog.addFilter(filter); - - String ormFileName = this.ormXmlName.getText(); - JpaXmlResource resource = jpaProject.getMappingFileXmlResource(new Path(ormFileName)); - IFile initialSelection = (resource != null) ? resource.getFile() : null; - dialog.setInput(project); - - if (initialSelection != null) { - dialog.setInitialSelection(initialSelection); - } - if (dialog.open() == Window.OK) { - this.model.setProperty(IEntityDataModelProperties.XML_NAME, dialog.getChosenName()); - } - } - - /** - * This method create filter for the browse/add alternative mapping XML - * @return new instance of viewer filter for the SelectMappingXMLDialog - */ - protected ViewerFilter getDialogViewerFilter(JpaProject jpaProject) { - return new XmlMappingFileViewerFilter(jpaProject); - } - - private void enableMappingXMLChooseGroup(boolean enabled) { - this.displayNameLink.setEnabled(enabled); - this.ormXmlName.setEnabled(enabled); - this.browseButton.setEnabled(enabled); - } - - /** - * This method is used by the project list initializer. The method checks - * if the specified project is valid to include it in the project list. - * - * <p>Subclasses of this wizard page should override this method to - * adjust filtering of the projects to their needs. </p> - * - * @param project reference to the project to be checked - * - * @return <code>true</code> if the project is valid to be included in - * the project list, <code>false</code> - otherwise. - */ - @Override - protected boolean isProjectValid(IProject project) { - return (project.isAccessible() && JpaFacet.isInstalled(project)); - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityFieldsWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityFieldsWizardPage.java deleted file mode 100644 index e36c8d0891..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityFieldsWizardPage.java +++ /dev/null @@ -1,234 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.IEntityDataModelProperties; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -public class EntityFieldsWizardPage extends DataModelWizardPage { - - private Text entityNameText; - private Text tableNameText; - private Button tableNameCheckButton; - private Button fieldAccessButton; - private Button propertyAccessButton; - private boolean isNonEntity = true; - private boolean isButtonsCreated = false; - - public EntityFieldsWizardPage(IDataModel model, String pageName) { - super(model, pageName); - this.setTitle(EntityWizardMsg.ENTITY_PROPERTIES_TITLE); - this.setDescription(EntityWizardMsg.ENTITY_PROPERTIES_DESCRIPTION); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - @Override - protected String[] getValidationPropertyNames() { - return new String[]{IEntityDataModelProperties.ENTITY_FIELDS, - IEntityDataModelProperties.PK_FIELDS}; - } - - /* Create the main composite and add to it the entity properties - * @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.NEW_JPA_ENTITY_ENTITY_PROPERTIES); - - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 300; - data.heightHint = 450; - composite.setLayoutData(data); - composite.pack(); - - entityNameText = createNameGroup(composite, EntityWizardMsg.ENTITY_NAME, IEntityDataModelProperties.ENTITY_NAME); - Group group = createGroup(composite, EntityWizardMsg.TABLE_NAME_GROUP); - tableNameCheckButton= createCheckButton(group, EntityWizardMsg.USE_DEFAULT, IEntityDataModelProperties.TABLE_NAME_DEFAULT); - tableNameText = createNameGroup(group, EntityWizardMsg.TABLE_NAME, IEntityDataModelProperties.TABLE_NAME); - tableNameText.setEnabled(!tableNameCheckButton.getSelection()); - isButtonsCreated = true; - initNameGroup(); - createEntityFieldsGroup(composite); - - Group accessTypeGroup = createGroup(composite, EntityWizardMsg.ACCESS_TYPE); - fieldAccessButton = createRadioButton(accessTypeGroup, EntityWizardMsg.FIELD_BASED, IEntityDataModelProperties.FIELD_ACCESS_TYPE); - propertyAccessButton = createRadioButton(accessTypeGroup, EntityWizardMsg.PROPERTY_BASED, IEntityDataModelProperties.PROPERTY_ACCESS_TYPE); - - - IStatus projectStatus = validateProjectName(); - if (!projectStatus.isOK()) { - setErrorMessage(projectStatus.getMessage()); - composite.setEnabled(false); - } - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * @return the status of the project name correctness - */ - protected IStatus validateProjectName() { - // check for empty - if (model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME) == null || model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME).trim().length() == 0) { - return WTPCommonPlugin.createErrorStatus(EntityWizardMsg.NO_JPA_PROJECTS); - } - return WTPCommonPlugin.OK_STATUS; - } - - protected void createEntityFieldsGroup(Composite parent) { - Group group = new Group(parent, SWT.NONE); - GridData groupGridData = new GridData(GridData.FILL_BOTH); - groupGridData.horizontalSpan = 3; - group.setLayoutData(groupGridData); - group.setLayout(new GridLayout(3, false)); - group.setText(EntityWizardMsg.ENTITY_FIELDS_GROUP); - new EntityRowTableWizardSection(group, model, IEntityDataModelProperties.ENTITY_FIELDS); - } - - /** - * Create named group - * @param parent the main composite - * @param label the name of the group - * @param property the related property to which this group will be synchronized - * @return the created group - */ - protected Text createNameGroup(Composite parent, String label, String property) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(3, false)); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Label displayNameLabel = new Label(composite, SWT.LEFT); - displayNameLabel.setText(label); - displayNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - Text nameText = new Text(composite, SWT.SINGLE | SWT.BORDER); - nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(nameText, property, /*dependentControls*/null); - return nameText; - } - - /** - * Create group - * @param parent the main composite - * @param text the name of the group - * @return the created group - */ - private Group createGroup(Composite parent, String text) { - Group group = new Group(parent, SWT.NONE); - GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL); - groupGridData.horizontalSpan = 3; - group.setLayoutData(groupGridData); - group.setLayout(new GridLayout(3, false)); - group.setText(text); - return group; - } - - /** - * Create check button - * @param parent the main composite - inheritance group - * @param text the label of the button - * @param property the related property to which this button will be synchronized - * @return the created button - */ - private Button createCheckButton(Composite parent, String text, String property) { - final Button button = new Button(parent, SWT.CHECK); - GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL); - groupGridData.horizontalSpan = 3; - button.setLayoutData(groupGridData); - button.setText(text); - button.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean isChecked = button.getSelection(); - if (tableNameText != null) { - tableNameText.setEnabled(!isChecked); - } - } - }); - synchHelper.synchCheckbox(button, property, /*dependentControls*/ null); - return button; - } - - /** - * Create radio button - * @param parent the main composite - inheritance group - * @param text the label of the button - * @param property the related property to which this button will be synchronized - * @return the created button - */ - private Button createRadioButton(Composite parent, String text, String property) { - Button button = new Button(parent, SWT.RADIO); - GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL); - groupGridData.horizontalSpan = 3; - button.setLayoutData(groupGridData); - button.setText(text); - synchHelper.synchRadio(button, property, /*dependentControls*/ null); - return button; - } - - /* - * If a property changes that we want to validate, force validation on this page. - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperationDataModelListener#propertyChanged(java.lang.String, - * java.lang.Object, java.lang.Object) - */ - @Override - public void propertyChanged(DataModelEvent event) { - String propertyName = event.getPropertyName(); - if (IEntityDataModelProperties.MAPPED_AS_SUPERCLASS.equals(propertyName)) { - initNameGroup(); - } - super.propertyChanged(event); - } - - /** - * The methods is for the internal use only. It will set the entity and table name - * group to be disabled if the created artifact is not entity - */ - private void initNameGroup() { - isNonEntity = model.getBooleanProperty(IEntityDataModelProperties.MAPPED_AS_SUPERCLASS); - if (isButtonsCreated) { - entityNameText.setEnabled(!isNonEntity); - tableNameCheckButton.setEnabled(!isNonEntity); - tableNameText.setEnabled(!tableNameCheckButton.getSelection()); - } - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } -} - - diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityRowTableWizardSection.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityRowTableWizardSection.java deleted file mode 100644 index af03ced040..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityRowTableWizardSection.java +++ /dev/null @@ -1,822 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2009 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.jface.bindings.keys.ParseException; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.fieldassist.ContentProposalAdapter; -import org.eclipse.jface.fieldassist.IContentProposalProvider; -import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; -import org.eclipse.jface.fieldassist.TextContentAdapter; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.EntityRow; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.IEntityDataModelProperties; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.dialogs.TypeSearchEngine; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * The class presents the table with entity fields. In the java file are included also content - * and label provider, add and edit entity dialogs as well as help internal objects - listener - * and callback from the dialog to the main composite (table). - * - */ -public class EntityRowTableWizardSection extends Composite { - - /** - * The possible entity types, mentioned in the specification (Chapter 2.1.1 Persistent Fields and Properties p.20) - */ - protected final static String[] VALID_TYPES = {"int", - "long", - "short", - "char", - "boolean", - "byte", - "double", - "float", - "java.lang.String", - "java.lang.Integer", - "java.lang.Long", - "java.lang.Short", - "java.lang.Character", - "java.lang.Boolean", - "java.lang.Byte", - "java.lang.Double", - "java.lang.Float", - "java.math.BigDecimal", - "java.math.BigInteger", - "java.util.Date", - "java.util.Calendar", - "java.sql.Date", - "java.sql.Time", - "java.sql.Timestamp", - "String", - "Integer", - "Long", - "Short", - "Character", - "Boolean", - "Byte", - "Double", - "Float" }; - - private CheckboxTableViewer mTableViewer = null; - private Table mTableWidget = null; - private final int NAME_COLUMN = 1; - private final int TYPE_COLUMN = 2; - - - - - private Button addButton; - private Button editButton; - private Button removeButton; - private String title = EntityWizardMsg.ENTITY_FIELDS_DIALOG_TITLE; - private String[] typeProposals = VALID_TYPES; - private String[] labelsForText = new String[]{EntityWizardMsg.TYPE_TEXT_FIELD, EntityWizardMsg.NAME_TEXT_FIELD}; - private IDataModel model; - private String propertyName; - private Image labelProviderImage = null; - private DialogCallback callback; - private static KeyStroke ks = null; - static { - try { - ks = KeyStroke.getInstance("Ctrl+Space"); - } catch (ParseException e1) { - JptJpaUiPlugin.log(e1); - } - } - - - /** - * @param parent the main composite - Entity fields page - * @param model the data model representation - * @param propertyName data property name - */ - public EntityRowTableWizardSection(Composite parent, IDataModel model, String propertyName) { - super(parent, SWT.NONE); - this.model = model; - this.propertyName = propertyName; - - GridLayout layout = new GridLayout(2, false); - layout.marginHeight = 4; - layout.marginWidth = 0; - this.setLayout(layout); - this.setLayoutData(new GridData(GridData.FILL_BOTH)); - - mTableWidget = new Table(this, SWT.CHECK | SWT.FULL_SELECTION | SWT.BORDER); - mTableWidget.setHeaderVisible(true); - mTableWidget.setLinesVisible(true); - - mTableViewer = new CheckboxTableViewer(mTableWidget); - GridData data = new GridData(GridData.FILL_BOTH); - data.verticalSpan = 2; - mTableWidget.setLayoutData(data); - mTableViewer.setContentProvider(new EntityRowContentProvider()); - mTableViewer.setLabelProvider(new EntityRowLabelProvider()); - - final Composite buttonComposition = new Composite(this, SWT.NULL); - layout = new GridLayout(); - layout.marginHeight = 0; - buttonComposition.setLayout(layout); - buttonComposition.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING)); - - addButton = new Button(buttonComposition, SWT.PUSH); - addButton.setText(EntityWizardMsg.ADD_BUTTON_LABEL); - addButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - addButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleAddButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - - editButton = new Button(buttonComposition, SWT.PUSH); - editButton.setText(EntityWizardMsg.EDIT_BUTTON_LABEL); - editButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - editButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleEditButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - editButton.setEnabled(false); - mTableViewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - handleEditButtonSelected(); - } - }); - - removeButton = new Button(buttonComposition, SWT.PUSH); - removeButton.setText(EntityWizardMsg.REMOVE_BUTTON_LABEL); - removeButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - removeButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleRemoveButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - removeButton.setEnabled(false); - - mTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (editButton != null) { - boolean enabled = ((IStructuredSelection) selection).size() == 1; - editButton.setEnabled(enabled); - } - removeButton.setEnabled(!selection.isEmpty()); - } - }); - - - final TableColumn pkColumn = new TableColumn(mTableWidget, SWT.CHECK); - pkColumn.setText(EntityWizardMsg.KEY); - pkColumn.pack(); - pkColumn.setResizable(false); - - TableColumn nameColumn = new TableColumn(mTableWidget, SWT.NONE); - nameColumn.setText(EntityWizardMsg.NAME_COLUMN); - - TableColumn typeColumn = new TableColumn(mTableWidget, SWT.NONE); - typeColumn.setText(EntityWizardMsg.TYPE_COLUMN); - - this.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - Table table = mTableViewer.getTable(); - TableColumn[] columns = table.getColumns(); - Point buttonArea = buttonComposition.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Rectangle area = table.getParent().getClientArea(); - Point preferredSize = mTableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT); - int width = area.width - 2 * table.getBorderWidth()- buttonArea.x - columns.length * 2 - pkColumn.getWidth(); - if (preferredSize.y > area.height + table.getHeaderHeight()) { - // Subtract the scrollbar width from the total column width - // if a vertical scrollbar will be required - Point vBarSize = table.getVerticalBar().getSize(); - width -= vBarSize.x; - } - Point oldSize = table.getSize(); - int consumeWidth = 0; - int col = columns.length - 1; - for (int i = 1; i < columns.length; i++) { - if (oldSize.x > area.width) { - // table is getting smaller so make the columns - // smaller first and then resize the table to - // match the client area width - consumeWidth = setColumntWidth(width, columns, consumeWidth, i); - table.setSize(area.width - buttonArea.x - (col * 2 + pkColumn.getWidth()), area.height); - } else { - // table is getting bigger so make the table - // bigger first and then make the columns wider - // to match the client area width - consumeWidth = setColumntWidth(width, columns, consumeWidth, i); - table.setSize(area.width - buttonArea.x - (col * 2 + pkColumn.getWidth()), area.height); - } - } - } - - private int setColumntWidth(int width, TableColumn[] columns, - int consumeWidth, int i) { - if (i < columns.length - 1) { - columns[i].setWidth(width / (columns.length - 1)); - consumeWidth += columns[i].getWidth(); - } else { - columns[i].setWidth(width - consumeWidth); - } - return consumeWidth; - } - }); - - mTableViewer.addCheckStateListener(new PKFieldCheckStateListener()); - callback = new FieldDialogCallback(); - } - - /** - * This method process the Add... button pressed event. It opens dialog to - * add new entity field - */ - private void handleAddButtonSelected() { - AddFieldDialog dialog = new AddFieldDialog(getShell(), title, typeProposals, labelsForText); - int result = dialog.open(); - if (result == Window.CANCEL) { - return; - } - EntityRow entityRow = dialog.getEntityRow(); - addEntityRow(entityRow); - } - - /** - * Add new entity to the table input - * - * @param entity - * the entity which have to be added to the table - */ - private void addEntityRow(EntityRow entity) { - if (entity == null) - return; - List<EntityRow> valueList = (ArrayList<EntityRow>) mTableViewer.getInput(); - if (valueList == null) - valueList = new ArrayList<EntityRow>(); - valueList.add(entity); - setInput(valueList); - } - - /** - * This method process the Edit... button pressed event. It opens dialog to edit chosen entity field - */ - private void handleEditButtonSelected() { - ISelection s = mTableViewer.getSelection(); - if (!(s instanceof IStructuredSelection)) - return; - IStructuredSelection selection = (IStructuredSelection) s; - if (selection.size() != 1) - return; - - Object selectedObj = selection.getFirstElement(); - EntityRow entityForEdit = (EntityRow) selectedObj; - int index = mTableWidget.getSelectionIndex(); - boolean isChecked = mTableViewer.getChecked(entityForEdit); - - EditFieldDialog dialog = new EditFieldDialog(getShell(), title, typeProposals, labelsForText, entityForEdit); - dialog.open(); - EntityRow entityRow = dialog.getEntityRow(); - if (entityRow != null) { - editEntityRow(index, entityRow); - mTableViewer.setChecked(entityRow, isChecked); - mTableViewer.setGrayed(entityRow, false); - } - } - - /** - * Edit chosen entity from the table - * @param index the index of the entity in the table - * @param newEntity the edited entity field - */ - private void editEntityRow(int index, EntityRow newEntity) { - if (newEntity == null) - return; - - List<EntityRow> valueList = (ArrayList<EntityRow>) mTableViewer.getInput(); - if (valueList == null) { - valueList = new ArrayList(); - } - - if (index == -1) { - valueList.add(newEntity); - } else { - valueList.set(index, newEntity); - } - - setInput(valueList); - } - - /** - * This method process the Remove button pressed event. - */ - private void handleRemoveButtonSelected() { - ISelection selection = mTableViewer.getSelection(); - if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) - return; - List selectedObject = ((IStructuredSelection) selection).toList(); - removeEntityRow(selectedObject); - } - - /** - * Removes the selected entities from the table - * @param entities list with entities, which should be removed - */ - private void removeEntityRow(Collection entities) { - List<EntityRow> valueList = (ArrayList<EntityRow>) mTableViewer.getInput(); - valueList.removeAll(entities); - setInput(valueList); - } - - /** - * Set the input of the table - * @param input the list with entities which have to be presented in the table - */ - private void setInput(List input) { - mTableViewer.setInput(input); - // Create a new list to trigger property change - ArrayList<EntityRow> newInput = new ArrayList<EntityRow>(); - newInput.addAll(input); - model.setProperty(propertyName, newInput); - } - - /** - * @return the TableViewer of the table - */ - public TableViewer getTableViewer() { - return mTableViewer; - } - - // PROVIDERS FOR THE FIELD TABLE - - /** - * The content provider for the table items - */ - protected class EntityRowContentProvider implements IStructuredContentProvider { - public boolean isDeleted(Object element) { - return false; - } - public Object[] getElements(Object element) { - if (element instanceof List) { - return ((List) element).toArray(); - } - return new Object[0]; - } - public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) { - //Default nothing - } - public void dispose() { - //Default nothing - } - } - - /** - * The label provider for the table items - */ - protected class EntityRowLabelProvider extends LabelProvider implements ITableLabelProvider { - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - return labelProviderImage; - } - return null; - } - - public String getColumnText(Object element, int columnIndex) { - EntityRow entity = (EntityRow) element; - if (columnIndex == NAME_COLUMN) { - return entity.getName(); - } - if (columnIndex == TYPE_COLUMN) { - return entity.getFqnTypeName(); - } - mTableViewer.setChecked(entity, entity.isKey()); - return ""; - } - - @Override - public Image getImage(Object element) { - return labelProviderImage; - } - - @Override - public String getText(Object element) { - String[] array = (String[]) element; - if (array.length > 0) { - return array[0]; - } else { - return super.getText(element); - } - } - } - // END - PROVIDERS FOR THE FIELD TABLE - - /** - * Listener for the Primary Key check box in the table item - */ - private class PKFieldCheckStateListener implements ICheckStateListener { - - public void checkStateChanged(CheckStateChangedEvent event) { - List<String> pkFields = new ArrayList<String>(); - TableItem[] children = mTableViewer.getTable().getItems(); - for (int i = 0; i < children.length; i++) { - TableItem item = children[i]; - EntityRow entityRow = (EntityRow)item.getData(); - entityRow.setKey(item.getChecked()); - if (item.getChecked()) - pkFields.add(entityRow.getName()); - } - model.setProperty(IEntityDataModelProperties.PK_FIELDS, pkFields); - } - - } - - // CALLBACK MECHANISM - /** - * Callback interface used by the Add/Edit-FieldDialog classes. - */ - public interface DialogCallback { - - /** - * Validates the text fields. - * <p>Used to decide whether to enable the OK button of the dialog. - * If the method returns <code>true</code> the OK button is enabled, - * otherwise the OK button is disabled.</p> - * @param combo contains the predefined types - * @param texts the name of the entity field - * @return <code>true</code> if the values in the text fields are - * valid, <code>false</code> otherwise. - */ - public boolean validate(Text type, Text[] texts); - - /** - * Retrieves the entity presentation object from the fields of the dialog. - * <p>Implementers of the callback can use these method to do some - * preprocessing (like trimming) of the data in the text fields before - * using it. The returned values will be the actual data that will be - * put in the table viewer.</p> - * @param combo contains the predefined types - * @param texts the name of the entity field - * @return the entity presentation object retrieved from the dialog - */ - public EntityRow retrieveResultStrings(Text type, Text[] texts); - - } - - /** - * Implementation of the <code>FieldDialogCallback</code> interface for - * both "Name" and "Types" table columns. - */ - public class FieldDialogCallback implements DialogCallback { - - /** - * The first text field should not be empty. - */ - public boolean validate(Text type, Text[] texts) { - if (texts.length > 0) { - IStatus validateFieldNameStatus = JavaConventions - .validateFieldName(texts[0].getText(), - JavaCore.VERSION_1_5, - JavaCore.VERSION_1_5); - if (!validateFieldNameStatus.isOK()) { - return false; - } - } - if (type.getText().equals("")) { - return false; - } - return true; - } - - /** - * Just retrieves the unmodified values of the text fields as a - * entity field presentation - * @see org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.EntityRow - */ - public EntityRow retrieveResultStrings(Text type, Text[] texts) { - EntityRow entity = new EntityRow(); - entity.setFqnTypeName(type.getText()); - entity.setName(texts[0].getText()); - return entity; - } - } - - // THE DIALOGS USED FOR ADD/EDIT OF ENTITY FIELDS - BEGIN - - /** - * The dialog which collect the information (name and type) for the new entity field - */ - private class AddFieldDialog extends Dialog implements ModifyListener, SelectionListener { - protected String windowTitle; - protected String[] typeProposals; - protected String[] labelsForText; - protected Text[] texts; - protected EntityRow entityRow; - protected Text attributeType; - protected ContentProposalAdapter contentProposalAdapter; - - /** - * Constructs AddFieldDialog - * @param shell - * @param windowTitle dialog label - * @param typeProposals the elements for the combo - * @param labelsForText name text - */ - public AddFieldDialog(Shell shell, String windowTitle, String[] typeProposals, String[] labelsForText) { - super(shell); - this.windowTitle = windowTitle; - this.typeProposals = typeProposals; - this.labelsForText = labelsForText; - } - - /* Create the area of dialog - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - @Override - public Control createDialogArea(Composite parent) { - - Composite composite = (Composite) super.createDialogArea(parent); - getShell().setText(windowTitle); - - GridLayout layout = new GridLayout(); - layout.numColumns = 4; - composite.setLayout(layout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.widthHint = 300; - composite.setLayoutData(data); - - Label label = new Label(composite, SWT.LEFT); - label.setText(labelsForText[0]); - label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - - attributeType = new Text(composite, SWT.SINGLE | SWT.BORDER);// | SWT.READ_ONLY); - //combo.setItems(labelsForCombo); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - attributeType.setLayoutData(data); - - Button browseButton = new Button(composite, SWT.PUSH); - browseButton.setText(EntityWizardMsg.BROWSE_BUTTON_LABEL); - GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - browseButtonData.horizontalSpan = 1; - browseButton.setLayoutData(browseButtonData); - browseButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - handleChooseEntityTypeButtonPressed(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - }); - - int n = labelsForText.length; - texts = new Text[n-1]; - for (int i = 1; i < n; i++) { - Label labelI = new Label(composite, SWT.LEFT); - labelI.setText(labelsForText[i]); - labelI.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - texts[i-1] = new Text(composite, SWT.SINGLE | SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - texts[i-1].setLayoutData(data); - } - - attributeType.setFocus(); - Dialog.applyDialogFont(parent); - createContentProposalProvider(); - return composite; - } - - private IContentProposalProvider createContentProposalProvider() { - SimpleContentProposalProvider contProvider = new SimpleContentProposalProvider(typeProposals); - contProvider.setFiltering(true); - - contentProposalAdapter = new ContentProposalAdapter( - attributeType, - new TextContentAdapter(), - contProvider, - ks, - new char[] {'b', 'c', 'd', 'i', 'f', 'l', 's', 'j', 'B', 'C', 'D', 'F', 'S', 'L', 'I'}); - contentProposalAdapter.setEnabled(true); - contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); - return contProvider; - } - - - /** - * Process browsing when the Browse... button have been pressed. Allow adding of entity field - * with arbitrary type. - */ - private void handleChooseEntityTypeButtonPressed() { - //getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); - IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT); - if (packRoot == null) { - return; - } - - // this eliminates the non-exported classpath entries - final IJavaSearchScope scope = TypeSearchEngine.createJavaSearchScopeForAProject(packRoot.getJavaProject(), true, true); - - // This includes all entries on the classpath. - SelectionDialog dialog=null; - try{ - dialog = JavaUI - .createTypeDialog( - getShell(), - null, - scope, - IJavaElementSearchConstants.CONSIDER_ALL_TYPES, - false); - } catch (JavaModelException e) { - JptJpaUiPlugin.instance().getLog().log(e.getStatus()); - return; - } - - dialog.setTitle(EntityWizardMsg.TYPE_DIALOG_TITLE); - dialog.setMessage(EntityWizardMsg.TYPE_DIALOG_DESCRIPTION); - - if (dialog.open() == Window.OK) { - IType type; - Object[] result = dialog.getResult(); - if (result == null || result.length == 0) { - type = null; - } - else type = (IType) result[0]; - String superclassFullPath = IEntityDataModelProperties.EMPTY_STRING; - if (type != null) { - superclassFullPath = type.getFullyQualifiedName(); - } - attributeType.setText(superclassFullPath); - //getControl().setCursor(null); - return; - } - //getControl().setCursor(null); - } - - - /* Create the content of the dialog - * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createContents(Composite parent) { - Composite composite = (Composite) super.createContents(parent); - - attributeType.addSelectionListener(this); - attributeType.addModifyListener(this); - for (int i = 0; i < texts.length; i++) { - texts[i].addModifyListener(this); - } - - updateOKButton(); - - return composite; - } - - /* Processes OK button pressed event. - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - @Override - protected void okPressed() { - entityRow = callback.retrieveResultStrings(attributeType, texts); - super.okPressed(); - } - - /** - * @return the entity representation with the information collected from the dialog - */ - public EntityRow getEntityRow() { - return entityRow; - } - - /* Processes text modifying event - * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) - */ - public void modifyText(ModifyEvent e) { - updateOKButton(); - } - - /** - * Sets state of the OK button in accordance with validate method of the callback object - * @see DialogCallback - */ - private void updateOKButton() { - getButton(IDialogConstants.OK_ID).setEnabled(callback.validate(attributeType, texts)); - } - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - /* Update OK button when the appropriate event occurs - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - updateOKButton(); - } - } - - /** - * Constructs EditFieldDialog - */ - private class EditFieldDialog extends AddFieldDialog { - protected EntityRow entityRow; - /** - * EditFieldDialog constructor comment. - */ - public EditFieldDialog(Shell shell, String windowTitle, String[] labelsForCombo, String[] labelsForText, EntityRow entity) { - super(shell, windowTitle, labelsForCombo, labelsForText); - this.entityRow = entity; - } - - /* Create the area of the dialog - * @see org.eclipse.jpt.jpa.ui.internal.wizards.entity.EntityRowTableWizardSection.AddFieldDialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - @Override - public Control createDialogArea(Composite parent) { - - Composite composite = (Composite) super.createDialogArea(parent); - - attributeType.setText(entityRow.getFqnTypeName()); - texts[0].setText(entityRow.getName()); - - return composite; - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityTemplate.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityTemplate.java deleted file mode 100644 index 42f6853d0a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityTemplate.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.*; -import java.util.*; - -public class EntityTemplate -{ - protected static String nl; - public static synchronized EntityTemplate create(String lineSeparator) - { - nl = lineSeparator; - EntityTemplate result = new EntityTemplate(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package "; - protected final String TEXT_2 = ";"; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL + "import "; - protected final String TEXT_5 = ";"; - protected final String TEXT_6 = NL + NL + "/**" + NL + " * Entity implementation class for Entity: "; - protected final String TEXT_7 = NL + " *" + NL + " */" + NL + "public class "; - protected final String TEXT_8 = " extends "; - protected final String TEXT_9 = " implements "; - protected final String TEXT_10 = ", "; - protected final String TEXT_11 = " {" + NL + "" + NL + "\t"; - protected final String TEXT_12 = " " + NL + "\tprivate "; - protected final String TEXT_13 = " "; - protected final String TEXT_14 = ";"; - protected final String TEXT_15 = NL + "\tprivate static final long serialVersionUID = 1L;\t" + NL + "\tpublic "; - protected final String TEXT_16 = "() {" + NL + "\t\tsuper();" + NL + "\t} " + NL + "\t"; - protected final String TEXT_17 = " " + NL + "\tpublic "; - protected final String TEXT_18 = " get"; - protected final String TEXT_19 = "() {" + NL + " \t\treturn this."; - protected final String TEXT_20 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void set"; - protected final String TEXT_21 = "("; - protected final String TEXT_22 = " "; - protected final String TEXT_23 = ") {" + NL + "\t\tthis."; - protected final String TEXT_24 = " = "; - protected final String TEXT_25 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_26 = NL + " " + NL + "}"; - protected final String TEXT_27 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - CreateEntityTemplateModel model = (CreateEntityTemplateModel) argument; -if (model.getJavaPackageName()!=null && model.getJavaPackageName()!="") { - stringBuffer.append(TEXT_1); - stringBuffer.append(model.getJavaPackageName()); - stringBuffer.append(TEXT_2); - } - stringBuffer.append(TEXT_3); - Collection<String> imports = model.getImports(false); -for (String anImport : imports) { - stringBuffer.append(TEXT_4); - stringBuffer.append(anImport); - stringBuffer.append(TEXT_5); - } - stringBuffer.append(TEXT_6); - stringBuffer.append(model.getEntityName()); - stringBuffer.append(TEXT_7); - stringBuffer.append(model.getClassName()); - String superClass = model.getSuperclassName(); - if (! "".equals(superClass)) { - stringBuffer.append(TEXT_8); - stringBuffer.append(superClass); - } - - List<String> interfaces = model.getInterfaces(); - if (interfaces.size()>0) { - stringBuffer.append(TEXT_9); - } - for (int i=0; i<interfaces.size(); i++) { - String INTERFACE = (String) interfaces.get(i); - if (i>0) { - stringBuffer.append(TEXT_10); - } - stringBuffer.append(INTERFACE); - } - stringBuffer.append(TEXT_11); - List<EntityRow> fields = model.getEntityFields(); - for (EntityRow entity : fields) { - - stringBuffer.append(TEXT_12); - stringBuffer.append(entity.getType()); - stringBuffer.append(TEXT_13); - stringBuffer.append(entity.getName()); - stringBuffer.append(TEXT_14); - } - stringBuffer.append(TEXT_15); - stringBuffer.append(model.getClassName()); - stringBuffer.append(TEXT_16); - - fields = model.getEntityFields(); - if (fields != null) for (int i=0; i<fields.size(); i++) { - EntityRow field = (EntityRow) fields.get(i); - String TYPE = field.getType(); - String NAME = field.getName(); - String METHOD = NAME.substring(0,1).toUpperCase() + NAME.substring(1); - - stringBuffer.append(TEXT_17); - stringBuffer.append(TYPE); - stringBuffer.append(TEXT_18); - stringBuffer.append(METHOD); - stringBuffer.append(TEXT_19); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_20); - stringBuffer.append(METHOD); - stringBuffer.append(TEXT_21); - stringBuffer.append(TYPE); - stringBuffer.append(TEXT_22); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_23); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_24); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_25); - } - stringBuffer.append(TEXT_26); - stringBuffer.append(TEXT_27); - return stringBuffer.toString(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityWizard.java deleted file mode 100644 index 9f302520ec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityWizard.java +++ /dev/null @@ -1,176 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.*; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.EntityDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEEditorUtility; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; - -public class EntityWizard - extends DataModelWizard - implements INewWizard { - - protected String initialProjectName; - - protected IStructuredSelection selection; - - /** - * Constructs the Entity wizard - * @param model the data model - */ - public EntityWizard(IDataModel model) { - super(model); - setWindowTitle(EntityWizardMsg.ENTITY_WIZARD_TITLE); - setDefaultPageImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.ENTITY_WIZ_BANNER)); - } - - /** - * Empty constructor - */ - public EntityWizard(){ - this(null); - } - - /* Adds the two pages of the entity wizard - * @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard#doAddPages() - */ - @Override - protected void doAddPages() { - EntityClassWizardPage page1 = new EntityClassWizardPage( - getDataModel(), - "pageOne", - EntityWizardMsg.ENTITY_WIZARD_PAGE_DESCRIPTION, - EntityWizardMsg.ENTITY_WIZARD_PAGE_TITLE); - page1.setProjectName(this.initialProjectName); - addPage(page1); - EntityFieldsWizardPage page2 = new EntityFieldsWizardPage(getDataModel(), "pageTwo"); - addPage(page2); - } - - public IStructuredSelection getSelection() { - return this.selection; - } - - /* Return the default data model provider (EntityDataModelProvider in our case) - * @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard#getDefaultProvider() - */ - @Override - protected IDataModelProvider getDefaultProvider() { - return new EntityDataModelProvider(); - } - - /* Check whether the mandatory information is set and wizard could finish - * @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard#canFinish() - */ - @Override - public boolean canFinish() { - return getDataModel().isValid(); - } - - /* - * Override the parent method in order to open the generated entity class in java editor - * @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard#postPerformFinish() - */ - @Override - protected void postPerformFinish() throws InvocationTargetException { - try { - String className = getDataModel().getStringProperty(QUALIFIED_CLASS_NAME); - IProject p = (IProject) getDataModel().getProperty(PROJECT); - IJavaProject javaProject = J2EEEditorUtility.getJavaProject(p); - IFile file = (IFile) javaProject.findType(className).getResource(); - openEditor(file); - } catch (Exception cantOpen) { - JptJpaUiPlugin.log(cantOpen); - } - } - - /** - * This method is intended for internal use only. It will open the file, sent as parameter - * in its own java editor - * @param file who should be opened - */ - private void openEditor(final IFile file) { - if (getDataModel().getBooleanProperty(OPEN_IN_EDITOR)) { - if (file != null) { - getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - try { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IDE.openEditor(page, file, true); - } - catch (PartInitException e) { - JptJpaUiPlugin.log(e); - } - } - }); - } - } - } - - /* Implement the abstract method from IWorkbenchWizard - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.selection = selection; - this.initialProjectName = extractProjectName(selection); - getDataModel(); - } - - protected String extractProjectName(IStructuredSelection selection) { - Object selectedObj = selection.getFirstElement(); - if (selectedObj instanceof IResource) { - return ((IResource) selectedObj).getProject().getName(); - } - if (selectedObj instanceof IJavaElement) { - return ((IJavaElement) selectedObj).getJavaProject().getProject().getName(); - } - if (selectedObj instanceof JpaContextNode) { - return ((JpaContextNode) selectedObj).getJpaProject().getProject().getName(); - } - - if (selectedObj instanceof IAdaptable) { - IResource resource = (IResource) ((IAdaptable) selectedObj).getAdapter(IResource.class); - if (resource != null) { - return resource.getProject().getName(); - } - IJavaElement javaElement = (IJavaElement) ((IAdaptable) selectedObj).getAdapter(IJavaElement.class); - if (javaElement != null) { - return javaElement.getJavaProject().getProject().getName(); - } - JpaContextNode node = (JpaContextNode) ((IAdaptable) selectedObj).getAdapter(JpaContextNode.class); - if (node != null) { - return node.getJpaProject().getProject().getName(); - } - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityWizardMsg.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityWizardMsg.java deleted file mode 100644 index 39acda138a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityWizardMsg.java +++ /dev/null @@ -1,127 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import com.ibm.icu.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import org.eclipse.osgi.util.NLS; - -public class EntityWizardMsg extends NLS { - - private static final String BUNDLE_NAME = "jpt_ui_entity_wizard";//$NON-NLS-1$ - private static ResourceBundle resourceBundle; - - public static String ENTITY_WIZARD_TITLE; - public static String ENTITY_WIZARD_PAGE_TITLE; - public static String ENTITY_WIZARD_PAGE_DESCRIPTION; - public static String DEFAULT_PACKAGE_WARNING; - public static String ENTITY_PROPERTIES_TITLE; - public static String ENTITY_PROPERTIES_DESCRIPTION; - public static String ENTITY; - public static String MAPPED_AS_SUPERCLASS; - public static String INHERITANCE_GROUP; - public static String INHERITANCE_CHECK_BOX; - public static String XML_STORAGE_GROUP; - public static String XML_SUPPORT; - public static String CHOOSE_XML; - public static String MAPPING_XML_TITLE; - public static String XML_NAME_TITLE; - public static String INVALID_XML_NAME; - public static String MAPPING_FILE_NOT_LISTED_ERROR; - public static String CHOOSE_MAPPING_XML_MESSAGE; - public static String TYPE_DIALOG_TITLE; - public static String TYPE_DIALOG_DESCRIPTION; - public static String ENTITY_NAME; - public static String TABLE_NAME; - public static String TABLE_NAME_GROUP; - public static String USE_DEFAULT; - public static String ENTITY_FIELDS_DIALOG_TITLE; - public static String ENTITY_FIELDS_GROUP; - public static String KEY; - public static String NAME_COLUMN; - public static String TYPE_COLUMN; - public static String NAME_TEXT_FIELD; - public static String TYPE_TEXT_FIELD; - public static String BROWSE_BUTTON_LABEL; - public static String ADD_BUTTON_LABEL; - public static String EDIT_BUTTON_LABEL; - public static String EntityDataModelProvider_typeNotInProjectClasspath; - public static String EntityDataModelProvider_invalidPKType; - public static String EntityDataModelProvider_invalidArgument; - public static String REMOVE_BUTTON_LABEL; - public static String DUPLICATED_ENTITY_NAMES_MESSAGE; - public static String ACCESS_TYPE; - public static String FIELD_BASED; - public static String PROPERTY_BASED; - public static String NO_JPA_PROJECTS; - public static String APPLY_CHANGES_TO_PERSISTENCE_XML; - public static String ADD_MAPPED_SUPERCLASS_TO_XML; - public static String ADD_ENTITY_TO_XML; - private EntityWizardMsg() { - // prevent instantiation of class - } - - static { - NLS.initializeMessages(BUNDLE_NAME, EntityWizardMsg.class); - } - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle(BUNDLE_NAME);//$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and getString(String) will return - // the key it was called with - } - return null; - } - - /** - * Returns the externalized string, mapped to this key - * @param key - * @return the text mapped to the key parameter - */ - public static String getString(String key) { - if (resourceBundle == null) { - resourceBundle = getResourceBundle(); - } - - if (resourceBundle != null) { - try { - return resourceBundle.getString(key); - } catch (MissingResourceException e) { - //exception during string obtaining - return "-" + key + "-";//$NON-NLS-2$//$NON-NLS-1$ - } - } - //return key, because the relevant string missing in the bundle - return "+" + key + "+";//$NON-NLS-2$//$NON-NLS-1$ - } - - /** - * Returns the formated string, mapped to this key - * @param key - * @param arguments - * @return the formated text, mapped to this key, with substituted arguments - */ - public static String getString(String key, Object[] arguments) { - try { - return MessageFormat.format(getString(key), arguments); - } catch (IllegalArgumentException e) { - return getString(key); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/IdClassTemplate.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/IdClassTemplate.java deleted file mode 100644 index 8c5f1b244c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/IdClassTemplate.java +++ /dev/null @@ -1,255 +0,0 @@ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity; - -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.*; -import java.util.*; - -public class IdClassTemplate -{ - protected static String nl; - public static synchronized IdClassTemplate create(String lineSeparator) - { - nl = lineSeparator; - IdClassTemplate result = new IdClassTemplate(); - nl = null; - return result; - } - - public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "package "; - protected final String TEXT_2 = ";"; - protected final String TEXT_3 = NL; - protected final String TEXT_4 = NL + "import "; - protected final String TEXT_5 = ";"; - protected final String TEXT_6 = NL + NL + "/**" + NL + " * ID class for entity: "; - protected final String TEXT_7 = NL + " *" + NL + " */ " + NL + "public class "; - protected final String TEXT_8 = " "; - protected final String TEXT_9 = " implements "; - protected final String TEXT_10 = ", "; - protected final String TEXT_11 = " { " + NL + " " + NL + "\t"; - protected final String TEXT_12 = " " + NL + "\tprivate "; - protected final String TEXT_13 = " "; - protected final String TEXT_14 = ";"; - protected final String TEXT_15 = NL + "\tprivate static final long serialVersionUID = 1L;" + NL + "" + NL + "\tpublic "; - protected final String TEXT_16 = "() {}" + NL + "" + NL + "\t"; - protected final String TEXT_17 = NL + NL + "\tpublic "; - protected final String TEXT_18 = " get"; - protected final String TEXT_19 = "() {" + NL + "\t\treturn this."; - protected final String TEXT_20 = ";" + NL + "\t}" + NL + "" + NL + "\tpublic void set"; - protected final String TEXT_21 = "("; - protected final String TEXT_22 = " "; - protected final String TEXT_23 = ") {" + NL + "\t\tthis."; - protected final String TEXT_24 = " = "; - protected final String TEXT_25 = ";" + NL + "\t}" + NL + "\t"; - protected final String TEXT_26 = NL + " " + NL + "\t/*" + NL + "\t * @see java.lang.Object#equals(Object)" + NL + "\t */\t" + NL + "\tpublic boolean equals(Object o) {" + NL + "\t\tif (o == this) {" + NL + "\t\t\treturn true;" + NL + "\t\t}" + NL + "\t\tif (!(o instanceof "; - protected final String TEXT_27 = ")) {" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\t"; - protected final String TEXT_28 = " other = ("; - protected final String TEXT_29 = ") o;" + NL + "\t\treturn true"; - protected final String TEXT_30 = NL + "\t\t\t&& "; - protected final String TEXT_31 = "() == other."; - protected final String TEXT_32 = "()"; - protected final String TEXT_33 = NL + "\t\t\t&& (Double.doubleToLongBits("; - protected final String TEXT_34 = "()) == Double.doubleToLongBits(other."; - protected final String TEXT_35 = "()))"; - protected final String TEXT_36 = NL + "\t\t\t&& (Float.floatToIntBits("; - protected final String TEXT_37 = "()) == Float.floatToIntBits(other."; - protected final String TEXT_38 = "()))"; - protected final String TEXT_39 = NL + "\t\t\t&& ("; - protected final String TEXT_40 = "() == null ? other."; - protected final String TEXT_41 = "() == null : "; - protected final String TEXT_42 = "().equals(other."; - protected final String TEXT_43 = "()))"; - protected final String TEXT_44 = ";" + NL + "\t}" + NL + "\t" + NL + "\t/*\t " + NL + "\t * @see java.lang.Object#hashCode()" + NL + "\t */\t" + NL + "\tpublic int hashCode() {" + NL + "\t\tfinal int prime = 31;" + NL + "\t\tint result = 1;"; - protected final String TEXT_45 = NL + "\t\tresult = prime * result + ("; - protected final String TEXT_46 = "() ? 1 : 0);"; - protected final String TEXT_47 = NL + "\t\tresult = prime * result + "; - protected final String TEXT_48 = "();"; - protected final String TEXT_49 = NL + "\t\tresult = prime * result + ((int) "; - protected final String TEXT_50 = "());"; - protected final String TEXT_51 = NL + "\t\tresult = prime * result + ((int) ("; - protected final String TEXT_52 = "() ^ ("; - protected final String TEXT_53 = "() >>> 32)));"; - protected final String TEXT_54 = NL + "\t\tresult = prime * result + ((int) (Double.doubleToLongBits("; - protected final String TEXT_55 = "() ) ^ (Double.doubleToLongBits("; - protected final String TEXT_56 = "()) >>> 32)));"; - protected final String TEXT_57 = NL + "\t\tresult = prime * result + Float.floatToIntBits("; - protected final String TEXT_58 = "());"; - protected final String TEXT_59 = NL + "\t\tresult = prime * result + ("; - protected final String TEXT_60 = "() == null ? 0 : "; - protected final String TEXT_61 = "().hashCode());"; - protected final String TEXT_62 = NL + "\t\treturn result;" + NL + "\t}" + NL + " " + NL + " " + NL + "}"; - protected final String TEXT_63 = NL; - - public String generate(Object argument) - { - final StringBuffer stringBuffer = new StringBuffer(); - CreateEntityTemplateModel model = (CreateEntityTemplateModel) argument; -if (model.getJavaPackageName()!=null && model.getJavaPackageName()!="") { - stringBuffer.append(TEXT_1); - stringBuffer.append(model.getJavaPackageName()); - stringBuffer.append(TEXT_2); - } - stringBuffer.append(TEXT_3); - Collection<String> imports = model.getImports(true); -for (String anImport : imports) { - stringBuffer.append(TEXT_4); - stringBuffer.append(anImport); - stringBuffer.append(TEXT_5); - } - stringBuffer.append(TEXT_6); - stringBuffer.append(model.getClassName()); - stringBuffer.append(TEXT_7); - stringBuffer.append(model.getIdClassName()); - stringBuffer.append(TEXT_8); - List<String> interfaces = model.getInterfaces(); - if (interfaces.size()>0) { - stringBuffer.append(TEXT_9); - } - for (int i=0; i<interfaces.size(); i++) { - String INTERFACE = (String) interfaces.get(i); - if (i>0) { - stringBuffer.append(TEXT_10); - } - stringBuffer.append(INTERFACE); - } - stringBuffer.append(TEXT_11); - List<EntityRow> fields = model.getEntityFields(); - List<String> pkFields = model.getPKFields(); - for (int i=0; i<fields.size(); i++) { - EntityRow entity = (EntityRow) fields.get(i); - if (!pkFields.contains(entity.getName())) { - continue; - } - - stringBuffer.append(TEXT_12); - stringBuffer.append(entity.getType()); - stringBuffer.append(TEXT_13); - stringBuffer.append(entity.getName()); - stringBuffer.append(TEXT_14); - } - stringBuffer.append(TEXT_15); - stringBuffer.append(model.getIdClassName()); - stringBuffer.append(TEXT_16); - - fields = model.getEntityFields(); - if (fields != null) for (int i=0; i<fields.size(); i++) { - EntityRow field = (EntityRow) fields.get(i); - String TYPE = field.getType(); - String NAME = field.getName(); - if (!pkFields.contains(NAME)) { - continue; - } - String METHOD = NAME.substring(0,1).toUpperCase() + NAME.substring(1); - - stringBuffer.append(TEXT_17); - stringBuffer.append(TYPE); - stringBuffer.append(TEXT_18); - stringBuffer.append(METHOD); - stringBuffer.append(TEXT_19); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_20); - stringBuffer.append(METHOD); - stringBuffer.append(TEXT_21); - stringBuffer.append(TYPE); - stringBuffer.append(TEXT_22); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_23); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_24); - stringBuffer.append(NAME); - stringBuffer.append(TEXT_25); - } - stringBuffer.append(TEXT_26); - stringBuffer.append(model.getIdClassName()); - stringBuffer.append(TEXT_27); - stringBuffer.append(model.getIdClassName()); - stringBuffer.append(TEXT_28); - stringBuffer.append(model.getIdClassName()); - stringBuffer.append(TEXT_29); - if (fields != null) for (int i=0; i<fields.size(); i++) { - EntityRow field = (EntityRow) fields.get(i); - String NAME = field.getName(); - if (!pkFields.contains(NAME)) { - continue; - } - String TYPE = field.getType(); - String GET_METHOD = "get" + NAME.substring(0,1).toUpperCase() + NAME.substring(1); - if (TYPE.equals("boolean") || TYPE.equals("byte") || TYPE.equals("char") || TYPE.equals("short") || TYPE.equals("int") || TYPE.equals("long")) { - stringBuffer.append(TEXT_30); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_31); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_32); - } else if (TYPE.equals("double")) { - stringBuffer.append(TEXT_33); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_34); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_35); - } else if (TYPE.equals("float")) { - stringBuffer.append(TEXT_36); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_37); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_38); - } else { - stringBuffer.append(TEXT_39); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_40); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_41); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_42); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_43); - } - } - stringBuffer.append(TEXT_44); - if (fields != null) for (int i=0; i<fields.size(); i++) { - EntityRow field = (EntityRow) fields.get(i); - String NAME = field.getName(); - if (!pkFields.contains(NAME)) { - continue; - } - String TYPE = field.getType(); - String GET_METHOD = "get" + NAME.substring(0,1).toUpperCase() + NAME.substring(1); - if (TYPE.equals("boolean")) { - stringBuffer.append(TEXT_45); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_46); - } else if (TYPE.equals("int")) { - stringBuffer.append(TEXT_47); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_48); - } else if (TYPE.equals("byte") || TYPE.equals("char") || TYPE.equals("short")) { - stringBuffer.append(TEXT_49); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_50); - } else if (TYPE.equals("long")) { - stringBuffer.append(TEXT_51); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_52); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_53); - } else if (TYPE.equals("double")) { - stringBuffer.append(TEXT_54); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_55); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_56); - } else if (TYPE.equals("float")) { - stringBuffer.append(TEXT_57); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_58); - } else { - stringBuffer.append(TEXT_59); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_60); - stringBuffer.append(GET_METHOD); - stringBuffer.append(TEXT_61); - } - } - stringBuffer.append(TEXT_62); - stringBuffer.append(TEXT_63); - return stringBuffer.toString(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java deleted file mode 100644 index 2f180bfae3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java +++ /dev/null @@ -1,384 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class CreateEntityTemplateModel { - - protected IDataModel dataModel; - - private static final String DOT = "."; //$NON-NLS-1$ - private static final String BRACKET = "["; //$NON-NLS-1$ - private static final String PK_SUFFIX = "PK"; //$NON-NLS-1$ - private static final String QUALIFIED_SERIALIZABLE = "java.io.Serializable"; //$NON-NLS-1$ - private static final String PERSISTENCE_PACKAGE = "javax.persistence.*"; //$NON-NLS-1$ - private static final String ENTITY_ANNOTATION = "@Entity"; //$NON-NLS-1$ - private static final String MAPPED_AS_SUPERCLASS_TYPE = "@MappedSuperclass"; //$NON-NLS-1$ - private static final String INHERITANCE_TYPE = "@Inheritance"; //$NON-NLS-1$ - - /** - * Constructs entity model as expansion of the data model - * @param dataModel - */ - public CreateEntityTemplateModel(IDataModel dataModel) { - this.dataModel = dataModel; - } - - /** - * Returns the necessary imports on depends of entity (primary keys) fields. It is used from - * JET emmiter when it generates entity (IdClass) - * @param isIdClass flag, which indicates the case. When it is false, the result is - * the import list for the entity class, in other case the results is the set for the IdClass - * generation - * @return the imports collection with the imports for the generated java class - */ - public Collection<String> getImports(boolean isIdClass) { - Collection<String> collection = new TreeSet<String>(); - - String className = getClassName(); - String superclassName = getQualifiedSuperclassName(); - - if (superclassName != null && superclassName.length() > 0 && - !equalSimpleNames(className, superclassName)) { - collection.add(superclassName); - } - - List interfaces = getQualifiedInterfaces(); - if (interfaces != null) { - Iterator iterator = interfaces.iterator(); - while (iterator.hasNext()) { - String iface = (String) iterator.next(); - if (!equalSimpleNames(getClassName(), iface)) { - collection.add(iface); - } - } - } - if (isIdClass) { - collection.addAll(getIdClassImportList()); - } else { - collection.add(PERSISTENCE_PACKAGE); - collection.addAll(getFieldImportList()); - - } - return collection; - } - - /** - * @return class name of the entity - */ - public String getClassName() { - return getProperty(INewJavaClassDataModelProperties.CLASS_NAME).trim(); - } - - /** - * @return package name when the entity will be generated - */ - public String getJavaPackageName() { - return getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE).trim(); - } - - /** - * @return fully qualified java class name - */ - public String getQualifiedJavaClassName() { - if (!getJavaPackageName().equals(IEntityDataModelProperties.EMPTY_STRING)) { - return getJavaPackageName() + DOT + getClassName(); - } - return getClassName(); - } - - /** - * @return the name - */ - public String getSuperclassName() { - String qualified = getQualifiedSuperclassName(); - if (equalSimpleNames(getClassName(), qualified)) { - return qualified; - } else { - return Signature.getSimpleName(qualified); - } - } - - /** - * @return fully qualified name of the entity's super class - */ - public String getQualifiedSuperclassName() { - return getProperty(INewJavaClassDataModelProperties.SUPERCLASS).trim(); - } - - /** - * @return list with the interfaces implemented from entity class - */ - public List<String> getInterfaces() { - List qualifiedInterfaces = getQualifiedInterfaces(); - List<String> interfaces = new ArrayList<String>(qualifiedInterfaces.size()); - - Iterator iter = qualifiedInterfaces.iterator(); - while (iter.hasNext()) { - String qualified = (String) iter.next(); - if (equalSimpleNames(getClassName(), qualified)) { - interfaces.add(qualified); - } else { - interfaces.add(Signature.getSimpleName(qualified)); - } - } - - return interfaces; - } - - /** - * @return list with the interfaces (fully qualified named) implemented from entity class - */ - public List getQualifiedInterfaces() { - List interfaces = (List) this.dataModel.getProperty(INewJavaClassDataModelProperties.INTERFACES); - if (interfaces == null){ - interfaces = new ArrayList(); - } - interfaces.add(QUALIFIED_SERIALIZABLE); - return interfaces; - } - - /** - * Returns the value of the specified string property - * @param propertyName - * @return string value of teh specified propert - */ - protected String getProperty(String propertyName) { - return dataModel.getStringProperty(propertyName); - } - - /** - * This methods is used for the comparison of fully qualified types - * @param name1 first type name - * @param name2 second type name - * @return whether the simple names of the types are equal - */ - protected boolean equalSimpleNames(String name1, String name2) { - String simpleName1 = Signature.getSimpleName(name1); - String simpleName2 = Signature.getSimpleName(name2); - return simpleName1.equals(simpleName2); - } - - /** - * @return the type of the artifact - Entity or Mapped superclass - */ - public String getArtifactType() { - if(dataModel.getBooleanProperty(IEntityDataModelProperties.MAPPED_AS_SUPERCLASS)) { - return MAPPED_AS_SUPERCLASS_TYPE; - } - return ENTITY_ANNOTATION; - } - - /** - * @return whether entity set inheritance strategy - */ - public boolean isInheritanceSet() { - return dataModel.getBooleanProperty(IEntityDataModelProperties.INHERITANCE); - } - - /** - * @return the name of the inheritance strategy, as it is defined in the specification - */ - public String getInheritanceStrategyName() { - return getProperty(IEntityDataModelProperties.INHERITANCE_STRATEGY); - } - - /** - * @return the constructed @Inheritance annotation with the relevant strategy - * if it is chosen - */ - public String getInheritanceStrategy() { - String result = IEntityDataModelProperties.EMPTY_STRING; - if (isInheritanceSet()) { - result = INHERITANCE_TYPE; - if (!getProperty(IEntityDataModelProperties.INHERITANCE_STRATEGY).equals(IEntityDataModelProperties.EMPTY_STRING)) { //$NON-NLS-1$ - result += "(strategy=InheritanceType." + getProperty(IEntityDataModelProperties.INHERITANCE_STRATEGY) + ")"; //$NON-NLS-1$ $NON-NLS-2$ - - } - } - return result; - } - - /** - * @return whether the generated artifact is not entity - */ - public boolean isNonEntitySuperclass() { - return !dataModel.getBooleanProperty(IEntityDataModelProperties.ENTITY); - } - - /** - * @return true the created artifact will be annotated - * @return false the entity mappings will be registered in XML - */ - public boolean isArtifactsAnnotated() { - return !dataModel.getBooleanProperty(IEntityDataModelProperties.XML_SUPPORT); - } - - public boolean isMappingXMLDefault() { - if (getMappingXMLName().equals(IEntityDataModelProperties.EMPTY_STRING)) { - return true; - } - return getMappingXMLName().equals(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString()); - } - - public String getMappingXMLName() { - return dataModel.getStringProperty(IEntityDataModelProperties.XML_NAME).trim(); - } - - public IFile getMappingXmlFile() { - IFile ormFile = null; - IProject project = getProject(); - IPackageFragmentRoot[] sourceFragments = J2EEProjectUtilities.getSourceContainers(project); - for (IPackageFragmentRoot packageFragmentRoot : sourceFragments) { - ormFile = project.getFile(packageFragmentRoot.getResource().getName() + File.separator + getMappingXMLName()); - if (ormFile.exists()) { - break; - } - } - return ormFile; - } - - /** - * @return the entity name (could be different from the class name) - * See <code>isEntityNameSet()<code> - */ - public String getEntityName() { - return getProperty(IEntityDataModelProperties.ENTITY_NAME).trim(); - } - - /** - * @return whether the entity name is different than class name - */ - public boolean isEntityNameSet() { - boolean result = false; - if (!getClassName().equals(getEntityName())) { - result = true; - } - return result; - } - - /** - * @return whether the table name is specified explicitly - */ - public boolean isTableNameSet() { - return !dataModel.getBooleanProperty(IEntityDataModelProperties.TABLE_NAME_DEFAULT); - } - - /** - * @return the table name (if it is specified) - * See <code>isTableNameSet()<code> - */ - public String getTableName() { - return getProperty(IEntityDataModelProperties.TABLE_NAME).trim(); - } - - /** - * @return list with the entity fields - */ - public List<EntityRow> getEntityFields() { - ArrayList<EntityRow> fields = (ArrayList<EntityRow>) dataModel.getProperty(IEntityDataModelProperties.ENTITY_FIELDS); - if (fields == null){ - return new ArrayList<EntityRow>(); - } else - return fields; - } - - /** - * @return list with the imports necessary for the entity (based on its fields) - */ - public List<String> getFieldImportList() { - List<String> imports = new ArrayList<String>(); - List<EntityRow> entities = getEntityFields(); - for (EntityRow entityRow : entities) { - if (!imports.contains(entityRow.getFqnTypeName()) && !entityRow.getType().equals(entityRow.getFqnTypeName())) { - String fqnTypeName = entityRow.getFqnTypeName(); - //remove the array brackets [] for the java.lang.Byte[] & java.lang.Character[] - if (fqnTypeName.indexOf(BRACKET) != -1) { - fqnTypeName = fqnTypeName.substring(0, fqnTypeName.indexOf("[")); - } - imports.add(fqnTypeName); - } - } - return imports; - } - /** - * @return list with the imports necessary for the id class (based on its fields - primary keys of the entity) - */ - public List<String> getIdClassImportList() { - List<String> imports = new ArrayList<String>(); - List<EntityRow> entities = getEntityFields(); - List<String> pkFields = getPKFields(); - for (EntityRow entityRow : entities) { - String name = entityRow.getName(); - if (pkFields.contains(name)) { - if (!imports.contains(entityRow.getFqnTypeName()) && !entityRow.getType().equals(entityRow.getFqnTypeName())) { - imports.add(entityRow.getFqnTypeName()); - } - } - } - return imports; - } - - /** - * @return whether the access type is field based - */ - public boolean isFieldAccess() { - return dataModel.getBooleanProperty(IEntityDataModelProperties.FIELD_ACCESS_TYPE); - } - - /** - * @return the primary key is composite (more than one annotated as primary key field) - */ - public boolean isCompositePK() { - return getPKFields().size() > 1; - } - - /** - * @return list with primary key name(s) - */ - public List<String> getPKFields() { - return (ArrayList<String>)dataModel.getProperty(IEntityDataModelProperties.PK_FIELDS); - } - - /** - * @return constructed name of the id class (entity name + PK as suffix) - */ - public String getIdClassName() { - return getClassName() + PK_SUFFIX; - } - - /** - * @return IProject presentation of JPA project - */ - public IProject getProject() { - String projectName = dataModel.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - return ProjectUtilities.getProject(projectName); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java deleted file mode 100644 index dab8489d17..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java +++ /dev/null @@ -1,504 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.EntityWizardMsg; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.operation.NewEntityClassOperation; -import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import com.ibm.icu.text.MessageFormat; - -public class EntityDataModelProvider extends NewJavaClassDataModelProvider implements IEntityDataModelProperties{ - - @Override - public IDataModelOperation getDefaultOperation() { - return new NewEntityClassOperation(getDataModel()); - } - - /** - * Extends: <code>IDataModelProvider#getPropertyNames()</code> - * and add own data model's properties specific for the entity model - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#getPropertyNames() - */ - @Override - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(INHERITANCE); - propertyNames.add(ENTITY); - propertyNames.add(MAPPED_AS_SUPERCLASS); - propertyNames.add(INHERITANCE_STRATEGY); - propertyNames.add(XML_SUPPORT); - propertyNames.add(XML_NAME); - propertyNames.add(ENTITY_NAME); - propertyNames.add(TABLE_NAME_DEFAULT); - propertyNames.add(TABLE_NAME); - propertyNames.add(ENTITY_FIELDS); - propertyNames.add(PK_FIELDS); - propertyNames.add(FIELD_ACCESS_TYPE); - propertyNames.add(PROPERTY_ACCESS_TYPE); - return propertyNames; - } - - /** - * Returns the default value of the parameter (which should present a valid data model property). - * This method does not accept a null parameter. It may return null. - * - * @see NewJavaClassDataModelProvider#getDefaultProperty(String) - * @see IDataModelProvider#getDefaultProperty(String) - * - * @param propertyName - * @return Object default value of property - */ - @Override - public Object getDefaultProperty(String propertyName) { - // overridden - if (propertyName.equals(SOURCE_FOLDER)) { - IContainer container = getDefaultJavaSourceContainer(); - return (container == null) ? null : container.getFullPath().toString(); - } - - else if (propertyName.equals(INHERITANCE)) { - return Boolean.FALSE; - } else if (propertyName.equals(ENTITY)) { - return Boolean.TRUE; - } else if (propertyName.equals(MAPPED_AS_SUPERCLASS)) { - return Boolean.FALSE; - } else if (propertyName.equals(XML_SUPPORT)) { - return Boolean.FALSE; - } else if (propertyName.equals(XML_NAME)) { - return EMPTY_STRING; - } else if (propertyName.equals(ENTITY_NAME)) { - return getStringProperty(CLASS_NAME); - } else if (propertyName.equals(TABLE_NAME_DEFAULT)) { - return Boolean.TRUE; - } else if (propertyName.equals(TABLE_NAME)) { - return getStringProperty(CLASS_NAME); - } else if (propertyName.equals(INHERITANCE_STRATEGY)) { - return EMPTY_STRING; - } else if (propertyName.equals(SUPERCLASS)) { - return EMPTY_STRING; - } else if (propertyName.equals(ENTITY_FIELDS)) { - return new ArrayList<EntityRow>(); - } else if (propertyName.equals(PK_FIELDS)) { - return new ArrayList<String>(); - } else if (propertyName.equals(FIELD_ACCESS_TYPE)) { - return Boolean.TRUE; - } else if (propertyName.equals(PROPERTY_ACCESS_TYPE)) { - return Boolean.FALSE; - } - // Otherwise check super for default value for property - return super.getDefaultProperty(propertyName); - } - - @Override - protected IFolder getDefaultJavaSourceFolder() { - return null; - } - - protected IContainer getDefaultJavaSourceContainer() { - JpaProject jpaProject = getTargetJpaProject(); - if (jpaProject == null) { - return null; - } - IJavaProject javaProject = jpaProject.getJavaProject(); - try { - for (IPackageFragmentRoot pfr : javaProject.getPackageFragmentRoots()) { - if (pfr.getKind() == IPackageFragmentRoot.K_SOURCE) { - return (IContainer) pfr.getUnderlyingResource(); - } - } - } - catch (JavaModelException jme) { - // fall through - JptJpaUiPlugin.log(jme); - } - return null; - } - - @Override - public boolean propertySet(String propertyName, Object propertyValue) { - boolean ok = super.propertySet(propertyName, propertyValue); - if (ok) { - if (COMPONENT_NAME.equals(propertyName) || PROJECT_NAME.equals(propertyName)) { - this.model.notifyPropertyChange(SOURCE_FOLDER, IDataModel.DEFAULT_CHG); - } - if (PROJECT_NAME.equals(propertyName) || XML_SUPPORT.equals(propertyName)) { - this.model.notifyPropertyChange(XML_NAME, IDataModel.VALID_VALUES_CHG); - } - } - return ok; - } - - /* Adds additional check to the model validation - * @see org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider#validate(java.lang.String) - */ - @Override - public IStatus validate(String propertyName) { - IStatus result = super.validate(propertyName); - if (propertyName.equals(JAVA_PACKAGE)) { - return validateJavaPackage(getStringProperty(propertyName)); - } - if (propertyName.equals(SUPERCLASS) && EMPTY_STRING.equals(getStringProperty(propertyName))) { - return WTPCommonPlugin.OK_STATUS; - } - if (propertyName.equals(XML_NAME)) { - return validateXmlName(getStringProperty(propertyName)); - } - if (propertyName.equals(ENTITY_FIELDS)) { - return validateFieldsList((ArrayList<EntityRow>) getProperty(propertyName)); - } - return result; - } - - @Override - protected IStatus validateJavaSourceFolder(String containerFullPath) { - // Ensure that the source folder path is not empty - if (containerFullPath == null || containerFullPath.length() == 0) { - String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NAME_EMPTY; - return WTPCommonPlugin.createErrorStatus(msg); - } - // Ensure that the source folder path is absolute - else if (!new Path(containerFullPath).isAbsolute()) { - String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_ABSOLUTE; - return WTPCommonPlugin.createErrorStatus(msg); - } - IProject project = getTargetProject(); - // Ensure project is not closed - if (project == null) { - String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_EXIST; - return WTPCommonPlugin.createErrorStatus(msg); - } - // Ensure project is accessible. - if (!project.isAccessible()) { - String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_EXIST; - return WTPCommonPlugin.createErrorStatus(msg); - } - // Ensure the project is a java project. - try { - if (!project.hasNature(JavaCore.NATURE_ID)) { - String msg = J2EECommonMessages.ERR_JAVA_CLASS_NOT_JAVA_PROJECT; - return WTPCommonPlugin.createErrorStatus(msg); - } - } catch (CoreException e) { - J2EEPlugin.logError(e); - } - // Ensure the selected folder is a valid java source folder for the component - IContainer container = getJavaSourceContainer(); - if (container == null || (! container.getFullPath().equals(new Path(containerFullPath)))) { - String msg = J2EECommonMessages.getResourceString(J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_SOURCE, new String[]{containerFullPath}); - return WTPCommonPlugin.createErrorStatus(msg); - } - // Valid source is selected - return WTPCommonPlugin.OK_STATUS; - } - - /** - * This method is intended for internal use only. It will be used to validate the correctness of entity package - * in accordance with Java convention requirements. This method will accept a null parameter. - * - * @see NewFilterClassDataModelProvider#validate(String) - * - * @param packName - * @return IStatus is the package name satisfies Java convention requirements - */ - - private IStatus validateJavaPackage(String packName) { - if (packName == null || packName.equals(EMPTY_STRING)) { - return WTPCommonPlugin.createWarningStatus(EntityWizardMsg.DEFAULT_PACKAGE_WARNING); - } - // Use standard java conventions to validate the package name - IStatus javaStatus = JavaConventions.validatePackageName(packName, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5); - if (javaStatus.getSeverity() == IStatus.ERROR) { - String msg = J2EECommonMessages.ERR_JAVA_PACAKGE_NAME_INVALID + javaStatus.getMessage(); - return WTPCommonPlugin.createErrorStatus(msg); - } else if (javaStatus.getSeverity() == IStatus.WARNING) { - String msg = J2EECommonMessages.ERR_JAVA_PACKAGE_NAME_WARNING + javaStatus.getMessage(); - return WTPCommonPlugin.createWarningStatus(msg); - } - // java package name is valid - return WTPCommonPlugin.OK_STATUS; - } - - /** - * This method is intended for internal use only. It will be used to validate - * the correctness of xml file location. - * This method will accept a null parameter. - * - * @see NewFilterClassDataModelProvider#validate(String) - * - * @param xmlName - * @return IStatus is the package name satisfies Java convention requirements - */ - private IStatus validateXmlName(String xmlName) { - if (getBooleanProperty(XML_SUPPORT)) { - String projectName = this.model.getStringProperty(PROJECT_NAME); - IProject project = ProjectUtilities.getProject(projectName); - if (project != null && ! StringTools.stringIsEmpty(xmlName)) { - JpaXmlResource ormXmlResource = getOrmXmlResource(xmlName); - if (ormXmlResource == null) { - return new Status( - IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, - EntityWizardMsg.INVALID_XML_NAME); - } - else if (getTargetJpaProject().getJpaFile(ormXmlResource.getFile()).rootStructureNodesSize() == 0) { - return new Status( - IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, - EntityWizardMsg.MAPPING_FILE_NOT_LISTED_ERROR); - } - } - } - return Status.OK_STATUS; - } - - protected JpaXmlResource getOrmXmlResource(String xmlName) { - return getTargetJpaProject().getMappingFileXmlResource(new Path(xmlName)); - } - - /** - * This method is intended for internal use only. It will be used to validate the entity fields - * list to ensure there are not any duplicates. This method will accept a null parameter. - * - * @see NewFilterClassDataModelProvider#validate(String) - * - * @param entities - * @return IStatus is the fields names are unique - */ - private IStatus validateFieldsList(ArrayList<EntityRow> entities) { - if (entities != null && !entities.isEmpty()) { - // Ensure there are not duplicate entries in the list - boolean dup = hasDuplicatesInEntityFields(entities); - if (dup) { - String msg = EntityWizardMsg.DUPLICATED_ENTITY_NAMES_MESSAGE; - return WTPCommonPlugin.createErrorStatus(msg); - } - // Ensure that the entries in the list are valid - String errorMsg = checkInputElementsTypeValidation(entities); - if (errorMsg != null) { - return WTPCommonPlugin.createErrorStatus(errorMsg); - } - String warningMsg = checkInputElementsTypeExistence(entities); - if (warningMsg != null) { - return WTPCommonPlugin.createWarningStatus(warningMsg); - } - } - return WTPCommonPlugin.OK_STATUS; - } - - private String checkInputElementsTypeValidation(List<EntityRow> inputElements) { - IStatus validateFieldTypeStatus = Status.OK_STATUS; - for (EntityRow entityRow: inputElements) { - if (entityRow.isKey() && !entityRow.couldBeKey()) { - String message = MessageFormat.format( - EntityWizardMsg.EntityDataModelProvider_invalidPKType, new Object[]{entityRow.getFqnTypeName()}); - validateFieldTypeStatus = new Status(IStatus.ERROR, - JptJpaUiPlugin.PLUGIN_ID, message); - break; - } - String sig = null; - try { - sig = Signature.createTypeSignature(entityRow.getFqnTypeName(), true); - } catch (IllegalArgumentException e) { - String message = MessageFormat.format(EntityWizardMsg.EntityDataModelProvider_invalidArgument, new Object[]{e.getLocalizedMessage()}); - validateFieldTypeStatus = new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, message); - break; - } - if (sig == null){ - validateFieldTypeStatus = JavaConventions.validateJavaTypeName(entityRow.getType(), JavaCore.VERSION_1_5, JavaCore.VERSION_1_5); - break; - } - int sigType = Signature.getTypeSignatureKind(sig); - if (sigType == Signature.BASE_TYPE_SIGNATURE) { - continue; - } - else if (sigType == Signature.ARRAY_TYPE_SIGNATURE) { - String elementSignature = Signature.getElementType(sig); - if (Signature.getTypeSignatureKind(elementSignature) == Signature.BASE_TYPE_SIGNATURE) { - continue; - } - } - } - if (!validateFieldTypeStatus.isOK()) { - return validateFieldTypeStatus.getMessage(); - } - return null; - } - - private String checkInputElementsTypeExistence(List<EntityRow> inputElements) { - IStatus validateFieldTypeStatus=Status.OK_STATUS; - for (EntityRow entityRow: inputElements) { - String sig = Signature.createTypeSignature(entityRow.getFqnTypeName() ,true); - if (sig == null) { - String message = MessageFormat.format( - EntityWizardMsg.EntityDataModelProvider_typeNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()}); - validateFieldTypeStatus = new Status(IStatus.ERROR, - JptJpaUiPlugin.PLUGIN_ID, message); - break; - } - int sigType = Signature.getTypeSignatureKind(sig); - if (sigType == Signature.BASE_TYPE_SIGNATURE){ - continue; - } - else if (sigType == Signature.ARRAY_TYPE_SIGNATURE) { - String elementSignature = Signature.getElementType(sig); - if(Signature.getTypeSignatureKind(elementSignature) == Signature.BASE_TYPE_SIGNATURE){ - continue; - } - String qualifiedName = Signature.toString(elementSignature); - IProject project = (IProject) getProperty(INewJavaClassDataModelProperties.PROJECT); - IJavaProject javaProject = JavaCore.create(project); - IType type = null; - try { - type = javaProject.findType(qualifiedName); - } catch (JavaModelException e) { - validateFieldTypeStatus = e.getStatus(); - break; - } - if (type == null) { - String message = MessageFormat.format( - EntityWizardMsg.EntityDataModelProvider_typeNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()}); - validateFieldTypeStatus = new Status(IStatus.ERROR, - JptJpaUiPlugin.PLUGIN_ID, message); - break; - } - } - else { - IProject project = (IProject) getProperty(INewJavaClassDataModelProperties.PROJECT); - IJavaProject javaProject = JavaCore.create(project); - IType type = null; - try { - type = javaProject.findType(entityRow.getFqnTypeName()); - } catch (JavaModelException e) { - validateFieldTypeStatus = e.getStatus(); - break; - } - if (type == null) { - String message = MessageFormat.format( - EntityWizardMsg.EntityDataModelProvider_typeNotInProjectClasspath, new Object[]{entityRow.getFqnTypeName()}); - validateFieldTypeStatus = new Status(IStatus.ERROR, - JptJpaUiPlugin.PLUGIN_ID, message); - break; - } - } - } - if(!validateFieldTypeStatus.isOK()) { - return validateFieldTypeStatus.getMessage(); - } - return null; - } - - - - /** - * This method is intended for internal use only. It provides a simple algorithm for detecting - * if there are duplicate entries in a list. It will accept a null parameter. It will return - * boolean. - * - * @param input - * @return boolean are there duplications in the list - */ - private boolean hasDuplicatesInEntityFields(ArrayList<EntityRow> input) { - if (input == null) { - return false; - } - int n = input.size(); - // nested for loops to check each element to see if other elements are the same - for (int i = 0; i < n; i++) { - EntityRow entity = input.get(i); - for (int j = i + 1; j < n; j++) { - EntityRow intEntity = input.get(j); - if (intEntity.getName().equals(entity.getName())) { - return true; - } - } - } - return false; - } - - protected JpaProject getTargetJpaProject() { - IProject project = getTargetProject(); - if (project != null && JpaFacet.isInstalled(project)) { - return JptJpaCorePlugin.getJpaProject(project); - } - return null; - } - - protected IContainer getJavaSourceContainer() { - String containerFullPath = getStringProperty(SOURCE_FOLDER); - JpaProject jpaProject = getTargetJpaProject(); - if (jpaProject == null) { - return null; - } - IJavaProject javaProject = jpaProject.getJavaProject(); - try { - for (IPackageFragmentRoot pfr : javaProject.getPackageFragmentRoots()) { - if (pfr.getKind() == IPackageFragmentRoot.K_SOURCE) { - IContainer container = (IContainer) pfr.getUnderlyingResource(); - if (container.getFullPath().equals(new Path(containerFullPath))) { - return container; - } - } - } - } - catch (JavaModelException jme) { - // fall through - JptJpaUiPlugin.log(jme); - } - return null; - } - - @Override - protected IPackageFragmentRoot getJavaPackageFragmentRoot() { - JpaProject jpaProject = getTargetJpaProject(); - if (jpaProject != null) { - IJavaProject javaProject = jpaProject.getJavaProject(); - // Return the source folder for the java project of the selected project - if (javaProject != null) { - IContainer sourceContainer = getJavaSourceContainer(); - if (sourceContainer != null) { - return javaProject.getPackageFragmentRoot(sourceContainer); - } - } - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/EntityRow.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/EntityRow.java deleted file mode 100644 index 5c029894e4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/EntityRow.java +++ /dev/null @@ -1,206 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2009 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model; - -import java.util.Arrays; -import java.util.List; - -public class EntityRow { - - private static final String DOT = "."; - private static final char BRACKET_SQUARE = '['; - private static final char BRACKET_ANGULAR = '<'; - private static final String PACKAGE_JAVA_LANG = "java.lang."; - private boolean key = false; - private String name = ""; - private String type = ""; - private String fqnTypeName = ""; - - private final static String[] PK_TYPES = {"int", "long", "short", "char", "boolean", "byte", "double", "float", - "java.lang.String", "java.sql.Date", "java.util.Date", "java.lang.Integer", "java.lang.Long", "java.lang.Short", - "java.lang.Character", "java.lang.Boolean", "java.lang.Byte", "java.lang.Double", "java.lang.Float"}; - - private final static String[] PK_TYPES_SHORT = { "String", "Integer", "Long", "Short", "Character", "Boolean", - "Byte", "Double", "Float" }; - - private final static List<String> VALID_PK_TYPES = Arrays.asList(PK_TYPES); - private final static List<String> VALID_PK_TYPES_SHORT = Arrays.asList(PK_TYPES_SHORT); - - /** - * @return whether the presented entity field is primary key or part of composite primary key - */ - public boolean isKey() { - return key; - } - - /** - * Sets the presented entity field to be primary key (or part of composite primari key) - * - * @param key - */ - public void setKey(boolean key) { - this.key = key; - } - - /** - * Check whether the type of the entity is allowed to be primary key. - * The limitation in the current implementation is that Embedded PK are not checked - * @return whether the type of field could be used as primary key - */ - public boolean couldBeKey() { - boolean result = false; - result = VALID_PK_TYPES.contains(getFqnTypeName()); - return result; - } - - /** - * @return the name of the entity field - */ - public String getName() { - return name; - } - - /** - * Sets the name of the presented entity field - * @param name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the type (as a simple name) of the entity field - */ - public String getType() { - return type; - } - - /** - * Sets the type (as a simple name) of the entity field - * - * @param type - */ - public void setType(String type) { - this.type = type; - } - - /** - * @return the type (as fully qualified name) of the entity field - */ - public String getFqnTypeName() { - return fqnTypeName; - } - - private String removeSpaces(String str) { - str = str.trim(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < str.length(); i++) { - char c = str.charAt(i); - if (!Character.isWhitespace(c)) - sb.append(c); - } - return sb.toString(); - } - - private String getBasicFQN(String fqn) { - String res; - int bsIndex = fqn.indexOf(BRACKET_SQUARE); - int baIndex = fqn.indexOf(BRACKET_ANGULAR); - if (bsIndex == -1) { - if (baIndex == -1) res = fqn; - else res = fqn.substring(0, baIndex); - } else { - if (baIndex == -1) res = fqn.substring(0, bsIndex); - else res = fqn.substring(0, Math.max(bsIndex, baIndex)); - } - return res; - } - - /** - * Sets the fully qualified type name of the entity field - * - * @param fqnTypeName - */ - public void setFqnTypeName(String fqnTypeName) { - fqnTypeName = removeSpaces(fqnTypeName); - String fqnBasicTypeName = getBasicFQN(fqnTypeName); - if (fqnBasicTypeName.indexOf(DOT) == -1) { - if (VALID_PK_TYPES_SHORT.contains(fqnBasicTypeName)) { - this.fqnTypeName = PACKAGE_JAVA_LANG + fqnTypeName; - setType(fqnTypeName); - } else { - this.fqnTypeName = fqnTypeName; - setType(fqnTypeName); - } - } else { - this.fqnTypeName = fqnTypeName; - setType(getSimpleName(fqnTypeName)); - } - } - - /** - * @return whether the type of the entity field is boolean. The information could be used - * when the name of getter should be constructed - */ - public boolean isBoolean() { - return "boolean".equals(getType()); - } - - /** - * For internal purpose only - * Convert fully qualified name to the simple one - * @param fullyName - * @return the simple name form the fully qualified name parameter(last segment) - */ - private String getSimpleName(String fullyName) { - return fullyName.substring(fullyName.lastIndexOf(DOT) + 1); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((fqnTypeName == null) ? 0 : fqnTypeName.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - /* - * Implement equals, depending from name of the entity field and its type. - * The type is presented from the fully qualified name - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final EntityRow other = (EntityRow) obj; - if (fqnTypeName == null) { - if (other.fqnTypeName != null) - return false; - } else if (!fqnTypeName.equals(other.fqnTypeName)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/IEntityDataModelProperties.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/IEntityDataModelProperties.java deleted file mode 100644 index 62ea483a2e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/model/IEntityDataModelProperties.java +++ /dev/null @@ -1,33 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model; - -import org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; - -public interface IEntityDataModelProperties extends INewJavaClassDataModelProperties, IAnnotationsDataModel { - - public static final String ENTITY = "IEntityDataModelProperties.ENTITY"; //$NON-NLS-1$ - public static final String MAPPED_AS_SUPERCLASS = "IEntityDataModelProperties.MAPPED_AS_SUPERCLASS"; //$NON-NLS-1$ - public static final String INHERITANCE = "IEntityDataModelProperties.INHERITANCE"; //$NON-NLS-1$ - public static final String INHERITANCE_STRATEGY = "IEntityDataModelProperties.INHERITANCE_STRATEGY"; //$NON-NLS-1$ - public static final String XML_SUPPORT = "IEntityDataModelProperties.XML_SUPPORT"; //$NON-NLS-1$XML_SUPPORT - public static final String XML_NAME = "IEntityDataModelProperties.XML_NAME"; //$NON-NLS-1$XML_SUPPORT - public static final String ENTITY_NAME = "IEntityDataModelProperties.ENTITY_NAME"; //$NON-NLS-1$ - public static final String TABLE_NAME_DEFAULT = "IEntityDataModelProperties.TABLE_NAME_DEFAULT"; //$NON-NLS-1$ - public static final String TABLE_NAME = "IEntityDataModelProperties.TABLE_NAME"; //$NON-NLS-1$ - public static final String ENTITY_FIELDS = "IEntityDataModelProperties.ENTITY_FIELDS"; //$NON-NLS-1$ - public static final String PK_FIELDS = "IEntityDataModelProperties.PK_FIELDS"; //$NON-NLS-1$ - public static final String FIELD_ACCESS_TYPE = "IEntityDataModelProperties.FIELD_ACCESS_TYPE"; //$NON-NLS-1$ - public static final String PROPERTY_ACCESS_TYPE = "IEntityDataModelProperties.PROPERTY_ACCESS_TYPE"; //$NON-NLS-1$ - public static final String EMPTY_STRING = ""; //$NON-NLS-1$ -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java deleted file mode 100644 index 1e612dbc85..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java +++ /dev/null @@ -1,537 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. - * 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: - * SAP AG - initial API and implementation - * Dimiter Dimitrov, d.dimitrov@sap.com - initial API and implementation - ***********************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.operation; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.emf.codegen.jet.JETEmitter; -import org.eclipse.emf.codegen.jet.JETException; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaModelMarker; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jpt.common.core.internal.utility.PlatformTools; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.InheritanceType; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.AnnotatedEntityTemplate; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.EntityTemplate; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.EntityWizardMsg; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.IdClassTemplate; -import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.CreateEntityTemplateModel; -import org.eclipse.jst.common.internal.annotations.controller.AnnotationsController; -import org.eclipse.jst.common.internal.annotations.controller.AnnotationsControllerManager; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.WTPJETEmitter; -import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditProviderOperation; -import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * The NewEntityClassOperation is IDataModelOperation following the - * IDataModel wizard and operation framework. - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * - * This operation is used to generate java classes for the new JPA entity. It uses - * EntityDataModelProvider to store the appropriate properties required to generate the new entity. - * @see org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.modelEntityDataModelProvider - * - * A WTPJetEmitter entity template is used to create the class with the entity template. - * @see org.eclipse.jst.j2ee.internal.project.WTPJETEmitter - * @see org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.CreateEntityTemplateModel - * - * The use of this class is EXPERIMENTAL and is subject to substantial changes. - */ -public class NewEntityClassOperation extends AbstractDataModelOperation { - - private static final String DOT_JAVA = ".java"; //$NON-NLS-1$ - private static final String SEPARATOR = "/";//$NON-NLS-1$ - private static final String VERSION_STRING = "1.0";//$NON-NLS-1$ - private static final String FIELD = "FIELD";//$NON-NLS-1$ - private static final String PROPERTY = "PROPERTY";//$NON-NLS-1$ - protected static final String WTP_CUSTOMIZATION_PLUGIN = "WTP_CUSTOMIZATION_PLUGIN"; //$NON-NLS-1$ - protected static final String ANNOTATED_ENTITY_TEMPLATE_FILE = "/templates/annotated_entity.javajet"; //$NON-NLS-1$ - protected static final String ENTITY_TEMPLATE_FILE = "/templates/entity.javajet"; //$NON-NLS-1$ - protected static final String IDCLASS_TEMPLATE_FILE = "/templates/idClass.javajet"; //$NON-NLS-1$ - protected static final String BUILDER_ID = "builderId"; //$NON-NLS-1$ - private static final String EMPTY_STRING = "";//$NON-NLS-1$ - private static final String SINGLE_TABLE = "SINGLE_TABLE";//$NON-NLS-1$ - - /** - * Method name of template implementation classes. - */ - protected static final String GENERATE_METHOD = "generate"; //$NON-NLS-1$ - - /** - * This is the constructor which should be used when creating a NewEntityClassOperation. - * An instance of the CreateEntityTemplateModel should be passed in. This does not accept - * null parameter. It will not return null. - * - * @see ArtifactEditProviderOperation#ArtifactEditProviderOperation(IDataModel) - * @see CreateEntityTemplateModel - * - * @param dataModel - * @return NewFilterClassOperation - */ - public NewEntityClassOperation(IDataModel dataModel) { - super(dataModel); - } - - /** - * The implementation of the execute method drives the running of the operation. - * This implementation will create the java source folder, create the java package, and then - * the entity (or mapped as superclass) and ID class files will be created using templates. - * - * @see org.eclipse.wst.common.frameworks.internal.operation.WTPOperation#execute(org.eclipse.core.runtime.IProgressMonitor) - * @see NewEntityClassOperation#generateUsingTemplates(IProgressMonitor, - * IPackageFragment) - * - * @param monitor - * @throws CoreException - * @throws InterruptedException - * @throws InvocationTargetException - */ - public IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // Create source folder if it does not exist - createJavaSourceContainer(); - // Create java package if it does not exist - IPackageFragment pack = createJavaPackage(); - // Generate filter class using templates - try { - generateUsingTemplates(monitor, pack); - } catch (Exception e) { - return WTPCommonPlugin.createErrorStatus(e.toString()); - } - return OK_STATUS; - } - - /** - * This method will return the java package as specified by the new java - * class data model. If the package does not exist, it will create the - * package. This method should not return null. - * - * @see INewJavaClassDataModelProperties#JAVA_PACKAGE - * @see IPackageFragmentRoot#createPackageFragment(java.lang.String, - * boolean, org.eclipse.core.runtime.IProgressMonitor) - * - * @return IPackageFragment the java package - */ - protected final IPackageFragment createJavaPackage() { - // Retrieve the package name from the java class data model - String packageName = model.getStringProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE); - IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model - .getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT); - IPackageFragment pack = packRoot.getPackageFragment(packageName); - // Handle default package - if (pack == null) { - pack = packRoot.getPackageFragment(""); //$NON-NLS-1$ - } - - // Create the package fragment if it does not exist - if (!pack.exists()) { - String packName = pack.getElementName(); - try { - pack = packRoot.createPackageFragment(packName, true, null); - } catch (JavaModelException e) { - JptJpaUiPlugin.log(e); - } - } - // Return the package - return pack; - } - - /** - * This implementation uses the creation of a CreateEntityTemplateModel and the WTPJETEmitter - * to create the java class with the annotated tags. This method accepts null for monitor, it does not accept null - * for fragment. If annotations are not being used the tags will be omitted from the class. - * - * @see CreateEntityTemplateModel - * @see NewEntityClassOperation#generateTemplateSource(CreateEntityTemplateModel, - * IProgressMonitor) - * - * @param monitor - * @param fragment - * @throws CoreException - * @throws WFTWrappedException - */ - protected void generateUsingTemplates(IProgressMonitor monitor, IPackageFragment fragment) throws WFTWrappedException, CoreException { - // Create the entity template model - CreateEntityTemplateModel tempModel = createTemplateModel(); - IProject project = getTargetProject(); - String entityClassSource = null; - String idClassSource = null; - // Generate the java source based on the entity template models - try { - if (tempModel.isArtifactsAnnotated()) { - AnnotatedEntityTemplate tempImpl = AnnotatedEntityTemplate.create(null); - entityClassSource = generateTemplateSource(tempModel, ANNOTATED_ENTITY_TEMPLATE_FILE, tempImpl, monitor); - } else { - EntityTemplate tempImpl = EntityTemplate.create(null); - entityClassSource = generateTemplateSource(tempModel, ENTITY_TEMPLATE_FILE, tempImpl, monitor); - } - if (tempModel.isCompositePK()) { - IdClassTemplate tempImpl = IdClassTemplate.create(null); - idClassSource = generateTemplateSource(tempModel, IDCLASS_TEMPLATE_FILE, tempImpl, monitor); - } - } catch (Exception e) { - throw new WFTWrappedException(e); - } - if (fragment != null) { - // Create the java file - String javaFileName = tempModel.getClassName() + DOT_JAVA; - ICompilationUnit cu = fragment.getCompilationUnit(javaFileName); - // Add the compilation unit to the java file - if (cu == null || !cu.exists()) { - cu = fragment.createCompilationUnit(javaFileName, entityClassSource, true, monitor); - } - IFile aFile = (IFile) cu.getResource(); - // Let the annotations controller process the annotated resource - if (tempModel.isArtifactsAnnotated()) { - AnnotationsController controller = AnnotationsControllerManager.INSTANCE.getAnnotationsController(project); - if (controller != null) { - controller.process(aFile); - } - } - //Create IdClass if the primary key is complex - if (idClassSource != null) { - String entityPKName = tempModel.getIdClassName() + DOT_JAVA; - ICompilationUnit cu1 = fragment.getCompilationUnit(entityPKName); - // Add the compilation unit to the java file - if (cu1 == null || !cu1.exists()) { - cu1 = fragment.createCompilationUnit(entityPKName, idClassSource, true, monitor); - } - } - } - - if (!tempModel.isArtifactsAnnotated()) { - if (tempModel.isNonEntitySuperclass()) { - addMappedSuperclassToXML(tempModel, project).schedule(); - } else { - addEntityToXML(tempModel, project).schedule(); - } - } - if (tempModel.isArtifactsAnnotated() && !JptJpaCorePlugin.discoverAnnotatedClasses(project)) { - registerClassInPersistenceXml(tempModel, project).schedule(); - } - } - - /** - * This method is intended for internal use only. This method will create an - * instance of the CreateEntityTemplateModel model to be used in conjunction - * with the WTPJETEmitter. This method will not return null. - * - * @see CreateEntityTemplateModel - * @see NewEntityClassOperation#generateUsingTemplates(IProgressMonitor, - * IPackageFragment) - * - * @return CreateFilterTemplateModel - */ - private CreateEntityTemplateModel createTemplateModel() { - CreateEntityTemplateModel templateModel = new CreateEntityTemplateModel(model); - return templateModel; - } - - /** - * This method is intended for internal use only. This will use the - * WTPJETEmitter to create an annotated java file based on the passed template model. - * This method does not accept null parameters. It will not return null. - * If annotations are not used, it will use the non annotated template to omit the annotated tags. - * - * @see NewEntityClassOperation#generateUsingTemplates(IProgressMonitor, - * IPackageFragment) - * @see JETEmitter#generate(org.eclipse.core.runtime.IProgressMonitor, - * java.lang.Object[]) - * @see CreateEntityTemplateModel - * - * @param templateModel - * @param monitor - * @param template_file - * @return String the source for the java file - * @throws JETException - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - private String generateTemplateSource(CreateEntityTemplateModel templateModel, String templateFile, Object templateImpl, IProgressMonitor monitor) - throws JETException, SecurityException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - Preferences preferences = J2EEPlugin.getDefault().getPluginPreferences(); - boolean dynamicTranslation = preferences.getBoolean(J2EEPlugin.DYNAMIC_TRANSLATION_OF_JET_TEMPLATES_PREF_KEY); - if (dynamicTranslation) { - URL templateURL = FileLocator.find(JptJpaUiPlugin.instance().getBundle(), new Path(templateFile), null); - cleanUpOldEmitterProject(); - WTPJETEmitter emitter = new WTPJETEmitter(templateURL.toString(), this.getClass().getClassLoader()); - emitter.setIntelligentLinkingEnabled(true); - emitter.addVariable(WTP_CUSTOMIZATION_PLUGIN, JptJpaUiPlugin.PLUGIN_ID); - return emitter.generate(monitor, new Object[] { templateModel }); - } else { - Method method = templateImpl.getClass().getMethod(GENERATE_METHOD, new Class[] { Object.class }); - return (String) method.invoke(templateImpl, templateModel); - } - } - - /** - * This method is intended for internal use only. It will clean up the old emmiter project - * in order to prevent generation issues - */ - private void cleanUpOldEmitterProject() { - IProject project = ProjectUtilities.getProject(WTPJETEmitter.PROJECT_NAME); - if (project == null || !project.exists()) - return; - try { - IMarker[] markers = project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); - for (int i = 0, l = markers.length; i < l; i++) { - if (((Integer) markers[i].getAttribute(IMarker.SEVERITY)).intValue() == IMarker.SEVERITY_ERROR) { - project.delete(true, new NullProgressMonitor()); - break; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * This method will return the java source container as specified in the java - * class data model. It will create the java source folder if it does not - * exist. This method may return null. - * - * @see INewJavaClassDataModelProperties#SOURCE_FOLDER - * @see IFolder#create(boolean, boolean, - * org.eclipse.core.runtime.IProgressMonitor) - * - * @return IFolder the java source folder - */ - protected final IContainer createJavaSourceContainer() { - // Get the source folder name from the data model - String containerFullPath = model.getStringProperty(INewJavaClassDataModelProperties.SOURCE_FOLDER); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IContainer container = PlatformTools.getContainer(new Path(containerFullPath)); - // If container does not exist, create the folder with the specified path - if (! container.exists()) { - try { - ((IFolder) container).create(true, true, null); - } catch (CoreException e) { - JptJpaUiPlugin.log(e); - } - } - // Return the source folder - return container; - } - - @Override - public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return doExecute(monitor, info); - } - - public IProject getTargetProject() { - String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - return ProjectUtilities.getProject(projectName); - } - - /** - * Adds entity to ORM XML in separate job - * @param model entity data model - * @param project JPA project in which the entity will be created - * @return - */ - private Job addEntityToXML(final CreateEntityTemplateModel model, final IProject project) { - Job job = new Job(EntityWizardMsg.ADD_ENTITY_TO_XML) { - @Override - protected IStatus run(IProgressMonitor monitor) { - final JpaXmlResource xmlResource = getOrmXmlResource(model, project); - EntityMappings entityMappings = (EntityMappings) JptJpaCorePlugin.getJpaProject(project).getJpaFile(xmlResource.getFile()).rootStructureNodes().next(); - OrmPersistentType persistentType = entityMappings.addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, model.getQualifiedJavaClassName()); - Entity entity = (Entity) persistentType.getMapping(); - if (model.isInheritanceSet()) { - entity.setSpecifiedInheritanceStrategy(getModelInheritanceType(model)); - } - - if (model.isEntityNameSet()) { - entity.setSpecifiedName(model.getEntityName()); - } - if (model.isTableNameSet()) { - entity.getTable().setSpecifiedName(model.getTableName()); - } - if (model.isCompositePK()) { - entity.getIdClassReference().setSpecifiedIdClassName(model.getIdClassName()); - } - for (String fieldName : model.getPKFields()) { - persistentType.getAttributeNamed(fieldName).convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); - } - - persistentType.setSpecifiedAccess(getModelAccessType(model)); - - try { - xmlResource.saveIfNecessary(); - } - catch (Exception e) { - JptJpaUiPlugin.log(e); - } - return Status.OK_STATUS; - } - }; - return job; - } - - protected JpaXmlResource getOrmXmlResource(CreateEntityTemplateModel model, IProject project) { - if (model.isMappingXMLDefault()) { - return JptJpaCorePlugin.getJpaProject(project).getDefaultOrmXmlResource(); - } - return JptJpaCorePlugin.getJpaProject(project).getMappingFileXmlResource(new Path(model.getMappingXMLName())); - } - - /** - * Adds mapped superclass to ORM XML in separate job - * - * @param model entity data model - * @param project JPA project in which the entity will be created - * @return the created job - */ - private Job addMappedSuperclassToXML(final CreateEntityTemplateModel model, final IProject project) { - Job job = new Job(EntityWizardMsg.ADD_MAPPED_SUPERCLASS_TO_XML) { - @Override - protected IStatus run(IProgressMonitor monitor) { - final JpaXmlResource xmlResource = getOrmXmlResource(model, project); - EntityMappings entityMappings = (EntityMappings) JptJpaCorePlugin.getJpaProject(project).getJpaFile(xmlResource.getFile()).rootStructureNodes().next(); - OrmPersistentType persistentType = entityMappings.addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, model.getQualifiedJavaClassName()); - MappedSuperclass mappedSuperclass = (MappedSuperclass) persistentType.getMapping(); - - if (model.isCompositePK()) { - mappedSuperclass.getIdClassReference().setSpecifiedIdClassName(model.getIdClassName()); - } - - for (String fieldName : model.getPKFields()) { - persistentType.getAttributeNamed(fieldName).convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); - } - - persistentType.setSpecifiedAccess(getModelAccessType(model)); - - try { - xmlResource.saveIfNecessary(); - } - catch (Exception e) { - JptJpaUiPlugin.log(e); - } - return Status.OK_STATUS; - } - }; - return job; - } - - protected AccessType getModelAccessType(CreateEntityTemplateModel model) { - String accessTypeString = FIELD; - if (!model.isFieldAccess()) { - accessTypeString = PROPERTY; - } - return AccessType.fromOrmResourceModel(OrmFactory.eINSTANCE.createAccessTypeFromString(null, accessTypeString));// TODO - } - - protected InheritanceType getModelInheritanceType(CreateEntityTemplateModel model) { - String inheritanceStrategy = model.getInheritanceStrategyName(); - if (inheritanceStrategy.equals(EMPTY_STRING)) { - inheritanceStrategy = SINGLE_TABLE; - } - return InheritanceType.fromOrmResourceModel(OrmFactory.eINSTANCE.createInheritanceTypeFromString(null, inheritanceStrategy));//TODO - } - - /** - * Regist the class in the persistence.xml - * - * @param model entity data model - * @param project JPA project in which the entity will be created - * @return the created job - */ - private Job registerClassInPersistenceXml(final CreateEntityTemplateModel model, final IProject project) { - Job job = new Job(EntityWizardMsg.APPLY_CHANGES_TO_PERSISTENCE_XML) { - @Override - protected IStatus run(IProgressMonitor monitor) { - final JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project); - final JpaXmlResource resource = jpaProject.getPersistenceXmlResource(); - resource.modify(new Runnable() { - public void run() { - XmlPersistence xmlPersistence = (XmlPersistence) resource.getRootObject(); - EList<XmlPersistenceUnit> persistenceUnits = xmlPersistence.getPersistenceUnits(); - XmlPersistenceUnit persistenceUnit = persistenceUnits.get(0);// Multiply persistence unit support - - if (!model.isNonEntitySuperclass()) { - XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef(); - classRef.setJavaClass(model.getQualifiedJavaClassName()); - persistenceUnit.getClasses().add(classRef); - } - } - }); - - return Status.OK_STATUS; - } - }; - return job; - - } - - /** - * @param input the name of mapping XML from the class wizard page. It is relative path from the source folder - * and includes META-INF folder - * @return the simple name of the mapping XML - */ - private String getLastSegment(String input) { - String output = input; - if (input.indexOf(SEPARATOR) != -1) { - output = input.substring(input.lastIndexOf(SEPARATOR) + 1); - } - return output; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationFigure.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationFigure.java deleted file mode 100644 index ccc474a7a6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationFigure.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import org.eclipse.draw2d.Button; -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.ConnectionEndpointLocator; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - - -class AssociationFigure extends Button { - - Color enabledColor = new Color( null, 14,66,115); - Color disabledLineColor = new Color( null, 192,215,231); - Color selectedColor = new Color( null, 232,232,232 ); - - Color selectedBorderColor = new Color( null, 14,66,115 ); - LineBorder selectedBorder = new LineBorder( selectedBorderColor, 2 ); - LineBorder unselectedBorder = new LineBorder( ColorConstants.lightGray, 1 ); - Font descriptionFont = new Font(null, "Arial", 8, SWT.NONE); - - /** - * The model behind the the view object - */ - Association association; - TableFigure tableFig1; - TableFigure tableFig2; - PolylineConnection connection ; - - PolygonDecoration referrerDecoration ; - PolygonDecoration referencedDecoration ; - - Label referencedLabel ; - Label referrerLabel ; - Label descriptionLabel ; - - AssociationFigure(Association association, ResourceManager resourceManager) { - this.association = association; - - XYLayout contentsLayout = new XYLayout(); - setLayoutManager(contentsLayout); - setBorder( unselectedBorder ); - - //Create the figures for referrer table and referenced table - tableFig1 = new TableFigure( association.getReferrerTable().getName(), resourceManager); - tableFig2 = new TableFigure( association.getReferencedTable().getName(), resourceManager); - - contentsLayout.setConstraint(tableFig1, new Rectangle(10,10,150,20)); - contentsLayout.setConstraint(tableFig2, new Rectangle(280, 10, 150, 20)); - - connection = drawConnection(tableFig1, tableFig2); - - add(tableFig1); - add(tableFig2); - add(connection); - - - descriptionLabel = new Label(""); - contentsLayout.setConstraint(descriptionLabel, new Rectangle(10,30,-1,-1)); - descriptionLabel.setFont( descriptionFont ); - add(descriptionLabel); - - //set white background - this.setBackgroundColor(ColorConstants.white); - - update(); - - } - - private PolylineConnection drawConnection(TableFigure tableFig1, - TableFigure tableFig2) { - /* Creating the connection */ - PolylineConnection connection = new PolylineConnection(); - ChopboxAnchor sourceAnchor = new ChopboxAnchor(tableFig1); - ChopboxAnchor targetAnchor = new ChopboxAnchor(tableFig2); - connection.setSourceAnchor(sourceAnchor); - connection.setTargetAnchor(targetAnchor); - - /* Creating the decoration */ - referrerDecoration = new SmoothPolygonDecoration(); - connection.setSourceDecoration(referrerDecoration); - - referencedDecoration = new SmoothPolygonDecoration(); - connection.setTargetDecoration(referencedDecoration); - - - /* Adding labels to the connection */ - ConnectionEndpointLocator sourceEndpointLocator = - new ConnectionEndpointLocator(connection, false); - sourceEndpointLocator.setVDistance(-5); - referrerLabel = new Label(""); - connection.add(referrerLabel, sourceEndpointLocator); - - ConnectionEndpointLocator targetEndpointLocator = - new ConnectionEndpointLocator(connection, true); - targetEndpointLocator.setVDistance(-5); - referencedLabel = new Label(""); - connection.add(referencedLabel, targetEndpointLocator); - - ConnectionEndpointLocator relationshipLocator = - new ConnectionEndpointLocator(connection,true); - relationshipLocator.setUDistance(10); - relationshipLocator.setVDistance(-20); - Label relationshipLabel = new Label("contains"); - connection.add(relationshipLabel,relationshipLocator); - return connection; - } - - public Association getAssociation() { - return this.association; - } - - @Override - public void setSelected ( boolean isSelected ){ - this.setBackgroundColor( isSelected ? selectedColor : ColorConstants.white ); - this.setBorder(isSelected? selectedBorder : unselectedBorder); - } - - /** - * Update the view with the changes user made on the model - */ - public void update(){ - boolean isGenerated = association.isGenerated(); - - connection.setForegroundColor( isGenerated? enabledColor: disabledLineColor ); - - tableFig1.setEnabled(isGenerated); - tableFig2.setEnabled(isGenerated); - descriptionLabel.setForegroundColor(isGenerated? enabledColor: disabledLineColor); - - //paintDirectionalityAndCardinality - String cardinalityStr; - String directionality = association.getDirectionality(); - String cardinality = association.getCardinality(); - //Draw referrerRole - if (cardinality.equals(Association.MANY_TO_ONE) || cardinality.equals(Association.MANY_TO_MANY)) { - cardinalityStr = "*"; - } else { - cardinalityStr = "1"; - } - if (directionality.equals(Association.BI_DI) || directionality.equals(Association.OPPOSITE_DI)) { - connection.setSourceDecoration(this.referrerDecoration); - }else{ - connection.setSourceDecoration(null); - } - - this.referrerLabel.setText( cardinalityStr ); - - //Draw referencedRole - if (cardinality.equals(Association.MANY_TO_ONE) || cardinality.equals(Association.ONE_TO_ONE)) { - cardinalityStr = "1"; - } else { - cardinalityStr = "*"; - } - if (directionality.equals(Association.BI_DI) || directionality.equals(Association.NORMAL_DI)) { - connection.setTargetDecoration(this.referencedDecoration); - }else{ - connection.setTargetDecoration(null); - } - this.referencedLabel.setText(cardinalityStr); - - String text = ""; - String referrerTableName = association.getReferrerTableName(); - String referencedTable = association.getReferencedTableName(); - if( cardinality.equals(Association.MANY_TO_ONE ) ){ - text = String.format( JptUiEntityGenMessages.manyToOneDesc, referencedTable , referrerTableName ); - }else if( cardinality.equals(Association.ONE_TO_ONE ) ){ - text = String.format( JptUiEntityGenMessages.oneToOneDesc, referrerTableName, referencedTable ); - }else if( cardinality.equals(Association.MANY_TO_MANY) ){ - text = String.format( JptUiEntityGenMessages.manyToManyDesc, referrerTableName, referencedTable, referencedTable, referrerTableName ); - } - - if( association.isCustom() ){ - connection.setLineStyle( SWT.LINE_DOT); - } - - this.descriptionLabel.setText(text); - - } - - public void dispose() { - this.descriptionFont.dispose(); - this.selectedBorderColor.dispose(); - this.selectedColor.dispose(); - this.disabledLineColor.dispose(); - this.enabledColor.dispose(); - this.tableFig1.dispose(); - this.tableFig2.dispose(); - } - - public class SmoothPolygonDecoration extends PolygonDecoration - { - public SmoothPolygonDecoration() - { - super(); - } - - @Override - public void paintFigure(Graphics graphics) - { - int savedAntialias = graphics.getAntialias(); - graphics.setAntialias(SWT.ON); - super.paintFigure(graphics); - graphics.setAntialias(savedAntialias); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationTablesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationTablesPage.java deleted file mode 100644 index e7fdbedacc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationTablesPage.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import static org.eclipse.jpt.jpa.ui.internal.wizards.gen.SWTUtil.createButton; -import static org.eclipse.jpt.jpa.ui.internal.wizards.gen.SWTUtil.createLabel; -import static org.eclipse.jpt.jpa.ui.internal.wizards.gen.SWTUtil.createText; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Text; - - - -public class AssociationTablesPage extends NewAssociationWizardPage { - - private Button simpleAssoBtn; - private Button mtmAssoBtn; - private Text table1TextField ; - private Text table2TextField ; - private Text joinTableTextField; - private Button joinTableBrowse; - - protected final ResourceManager resourceManager; - - public AssociationTablesPage(ORMGenCustomizer customizer, ResourceManager resourceManager) { - super(customizer, "AssociationTablesPage"); - this.resourceManager = resourceManager; - setTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_title); - setDescription(JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_desc); - } - - public void createControl(Composite composite) { - initializeDialogUnits(composite); - Composite parent = new Composite(composite, SWT.NONE); - parent.setLayout(new GridLayout(1, true)); - - Group assocKindGroup = new Group(parent, SWT.NULL); - int nColumns= 3 ; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - assocKindGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - assocKindGroup.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_ASSOCIATION_TABLES); - assocKindGroup.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_assocKind); - - simpleAssoBtn = createButton(assocKindGroup, 3, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_simpleAssoc, SWT.RADIO); - mtmAssoBtn = createButton(assocKindGroup, 3, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_m2mAssoc, SWT.RADIO); - - - Group assocTablesGroup = new Group(parent, SWT.NULL); - nColumns= 3 ; - layout = new GridLayout(); - layout.numColumns = nColumns; - assocTablesGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - assocTablesGroup.setLayout(layout); - - - assocTablesGroup.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_assocTables ); - - createLabel(assocTablesGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_table1); - table1TextField = createText(assocTablesGroup, 1); - - Button browser1 = createButton(assocTablesGroup, 1, "", SWT.NONE); - browser1.setImage( ImageRepository.getBrowseButtonImage(this.resourceManager)); - - browser1.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - SelectTableDialog dlg = new SelectTableDialog(Display.getDefault().getActiveShell(), resourceManager, customizer.getTableNames()); - if( dlg.open() ==Dialog.OK ){ - table1TextField.setText( dlg.getSelectedTable() ); - getWizardDataModel().put( NewAssociationWizard.ASSOCIATION_REFERRER_TABLE, table1TextField.getText()); - getWizard().getContainer().updateButtons(); - ((NewAssociationWizard)getWizard()).updateTableNames(); - } - } - }); - - createLabel(assocTablesGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_table2); - table2TextField = createText(assocTablesGroup, 1); - - Button browser2 = createButton(assocTablesGroup, 1, "", SWT.NONE); - browser2.setImage( ImageRepository.getBrowseButtonImage(this.resourceManager)); - - browser2.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - SelectTableDialog dlg = new SelectTableDialog( Display.getDefault().getActiveShell(), resourceManager, customizer.getSchema() ); - if( dlg.open() == Dialog.OK){ - table2TextField.setText( dlg.getSelectedTable() ); - getWizardDataModel().put( NewAssociationWizard.ASSOCIATION_REFERENCED_TABLE, table2TextField.getText()); - ((NewAssociationWizard)getWizard()).updateTableNames(); - } - updatePageComplete(); - } - }); - - createLabel(assocTablesGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_intermediateTable ); - joinTableTextField = createText(assocTablesGroup, 1); - joinTableTextField.setEnabled(false); - - joinTableBrowse = createButton(assocTablesGroup, 1, "", SWT.NONE); - joinTableBrowse.setImage( ImageRepository.getBrowseButtonImage(this.resourceManager)); - joinTableBrowse.setEnabled(false); - - joinTableBrowse.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - SelectTableDialog dlg = new SelectTableDialog( Display.getDefault().getActiveShell(), resourceManager, customizer.getSchema() ); - if( dlg.open() == Dialog.OK){ - joinTableTextField.setText( dlg.getSelectedTable() ); - getWizardDataModel().put( NewAssociationWizard.ASSOCIATION_JOIN_TABLE, joinTableTextField.getText() ); - ((NewAssociationWizard)getWizard()).updateTableNames(); - getWizard().getContainer().updateButtons(); - } - updatePageComplete(); - } - }); - - setControl(parent); - - simpleAssoBtn.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - joinTableTextField.setEnabled(false); - joinTableTextField.clearSelection(); - joinTableTextField.setText(""); - joinTableBrowse.setEnabled(false); - getWizardDataModel().put( NewAssociationWizard.ASSOCIATION_CADINALITY, Association.MANY_TO_ONE); - getWizardDataModel().remove( NewAssociationWizard.ASSOCIATION_JOIN_TABLE ); - ((NewAssociationWizard)getWizard()).updateTableNames(); - updatePageComplete(); - } - - }); - - mtmAssoBtn.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - joinTableTextField.setEnabled(true); - joinTableBrowse.setEnabled(true); - getWizardDataModel().put( NewAssociationWizard.ASSOCIATION_CADINALITY, Association.MANY_TO_MANY); - ((NewAssociationWizard)getWizard()).updateTableNames(); - updatePageComplete(); - } - }); - - this.setPageComplete( false); - table1TextField.setFocus(); - } - - @Override - public boolean canFlipToNextPage() { - return isPageComplete(); - } - - public void updatePageComplete() { - if( this.table1TextField.getText().length() <= 0){ - setPageComplete(false); - return; - } - if( mtmAssoBtn.getSelection() ){ - if( this.joinTableTextField.getText().length() <= 0 ){ - setPageComplete(false); - return; - } - } - setPageComplete(true); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationsListComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationsListComposite.java deleted file mode 100644 index 65e1978e48..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/AssociationsListComposite.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.List; - -import org.eclipse.draw2d.ActionEvent; -import org.eclipse.draw2d.ActionListener; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -/** - * A Draw2d figure representing list of associations between two database tables - * - */ -public class AssociationsListComposite extends FigureCanvas { - - List<Association> associations; - AssociationToggleSelectionListener listener ; - TableAssociationsWizardPage tableAssociationsWizardPage; //the parent wizard page - AssociationFigure selectedAssociationFigure ; - - protected final ResourceManager resourceManager; - - public AssociationsListComposite(Composite parent, TableAssociationsWizardPage tableAssociationsWizardPage, ResourceManager resourceManager){ - super(parent); - this.tableAssociationsWizardPage = tableAssociationsWizardPage; - this.resourceManager = resourceManager; - - setBounds(10, 10 , 500, 200); - Color backgroundColor = new Color(Display.getDefault(), 255,255,255); - setBackground(backgroundColor); - backgroundColor.dispose(); - - Figure figure = new Figure(); - figure.setLayoutManager(new ToolbarLayout()); - figure.setBorder(new LineBorder(1)); - this.listener = new AssociationToggleSelectionListener(); - - this.setContents(figure); - } - - public void updateAssociations(List<Association> associations){ - Figure figure = (Figure)this.getContents(); - this.disposeFigure(figure); - - this.associations = associations; - if( associations != null ){ - for( int i = 0; i <associations.size(); i ++ ){ - Association association = associations.get(i); - AssociationFigure assocFigure = new AssociationFigure(association, this.resourceManager); - assocFigure.addActionListener( listener ); - figure.add(assocFigure); - } - } - } - - public Association getSelectedAssociation(){ - return this.selectedAssociationFigure.getAssociation(); - } - - @SuppressWarnings("unchecked") - public void updateSelectedAssociation(){ - Figure figure = (Figure)this.getContents(); - List<AssociationFigure> associationFigures = figure.getChildren(); - for(AssociationFigure assocFig : associationFigures){ - if( assocFig == this.selectedAssociationFigure){ - assocFig.update(); - } - } - } - - /** - * Get the association just before the selected one in UI - * @return - */ - @SuppressWarnings("unchecked") - public Association getPreviousAssociation(){ - Figure figure = (Figure)this.getContents(); - List<AssociationFigure> associationFigures = figure.getChildren(); - AssociationFigure ret = null; - for(AssociationFigure assocFig : associationFigures){ - if( assocFig.isSelected() ){ - break; - } - ret = assocFig; - } - return ret==null?null:ret.getAssociation(); - } - - @Override - public void dispose() { - this.disposeFigure((Figure) getContents()); - super.dispose(); - } - - @SuppressWarnings("unchecked") - protected void disposeFigure(Figure figure) { - for (AssociationFigure associationFigure : (List<AssociationFigure>) figure.getChildren()) { - associationFigure.removeActionListener(this.listener); - associationFigure.dispose(); - } - figure.removeAll(); - this.selectedAssociationFigure = null; - } - - class AssociationToggleSelectionListener implements ActionListener { - public void actionPerformed(ActionEvent event) { - AssociationFigure figure = (AssociationFigure )event.getSource() ; - figure.setSelected(true); - Association association = figure.getAssociation(); - tableAssociationsWizardPage.updateAssociationEditPanel(association); - //un-select the previous selected - if( selectedAssociationFigure != null && selectedAssociationFigure!= figure ){ - selectedAssociationFigure.setSelected( false ); - } - //Highlight new selection - selectedAssociationFigure = figure; - selectedAssociationFigure.setSelected( true ); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/CardinalityPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/CardinalityPage.java deleted file mode 100644 index fca73e4df8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/CardinalityPage.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.wizards.gen; - -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - - -public class CardinalityPage extends NewAssociationWizardPage { - - private Label mtoDescLabel; - private Label otmDescLabel; - private Label otoDescLabel; - private Label mtmDescLabel; - - private Button[] cardinalityButtons = new Button[4]; - - protected CardinalityPage(ORMGenCustomizer customizer) { - super( customizer , "CardinalityPage" ); - setTitle(JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_cardinalityPage_title); - setDescription( JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_cardinalityPage_desc); - } - - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 1 ; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_ASSOCIATION_CARDINALITY); - - CardinalitySelectionListener selectionListener = new CardinalitySelectionListener(); - cardinalityButtons[0] = createRadioButton( composite, 1, JptUiEntityGenMessages.manyToOne); - cardinalityButtons[0].addSelectionListener( selectionListener ); - //Default cardinality is MTO - cardinalityButtons[0].setSelection(true); - getWizardDataModel().put(NewAssociationWizard.ASSOCIATION_CADINALITY, Association.MANY_TO_ONE); - - mtoDescLabel = createLabel(composite,1, JptUiEntityGenMessages.manyToOneDesc); - - cardinalityButtons[1] = createRadioButton( composite, 1, JptUiEntityGenMessages.oneToMany); - cardinalityButtons[1].addSelectionListener( selectionListener ); - - otmDescLabel = createLabel(composite,1, JptUiEntityGenMessages.manyToOneDesc); - - cardinalityButtons[2] = createRadioButton( composite, 1, JptUiEntityGenMessages.oneToOne); - cardinalityButtons[2].addSelectionListener( selectionListener ); - - otoDescLabel = createLabel(composite,1, JptUiEntityGenMessages.oneToOneDesc); - - cardinalityButtons[3] = createRadioButton( composite, 1, JptUiEntityGenMessages.manyToMany); - mtmDescLabel= createLabel(composite,1, JptUiEntityGenMessages.manyToManyDesc); - - setControl(composite); - this.setPageComplete( true ); - - cardinalityButtons[0].setFocus(); - - } - - public void updateWithNewTables() { - String s1 = getReferrerTableName() ; - String s2 = getReferencedTableName() ; - String joinTableName = getJoinTableName(); - if( s1 == null || s2 == null ) - return ; - - updateDescriptionText(s1, s2); - if( joinTableName == null ){ - cardinalityButtons[0].setEnabled(true); - cardinalityButtons[1].setEnabled(true); - cardinalityButtons[2].setEnabled(true); - cardinalityButtons[3].setEnabled(false); - mtmDescLabel.setEnabled(false); - }else{ - cardinalityButtons[0].setEnabled(false); - cardinalityButtons[1].setEnabled(false); - cardinalityButtons[2].setEnabled(false); - cardinalityButtons[3].setEnabled(true); - cardinalityButtons[3].setSelection(true); - mtmDescLabel.setEnabled(true); - } - ((Composite)this.getControl()).layout() ; - } - - private void updateDescriptionText(String s1, String s2) { - //MTO - String msg = String.format(JptUiEntityGenMessages.manyToOneDesc, s2, s1); - mtoDescLabel.setText( msg ); - //OTM - msg = String.format(JptUiEntityGenMessages.manyToOneDesc, s1, s2); - otmDescLabel.setText( msg ); - msg = String.format(JptUiEntityGenMessages.oneToOneDesc, s1, s2); - otoDescLabel.setText( msg ); - msg = String.format(JptUiEntityGenMessages.manyToManyDesc, s1, s2, s2, s1); - mtmDescLabel.setText( msg ); - } - - public boolean canFlipToNextPage() { - return false; - } - - private Label createLabel(Composite container, int span, String text) { - Label label = new Label(container, SWT.NONE); - label.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - gd.horizontalIndent = 30; - label.setLayoutData(gd); - return label; - } - - - private Button createRadioButton(Composite container, int span, String text ) { - Button btn = new Button(container, SWT.RADIO ); - btn.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - btn.setLayoutData(gd); - return btn; - } - - - private class CardinalitySelectionListener implements SelectionListener { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - if( e.getSource() == cardinalityButtons[0]){ - getWizardDataModel().put(NewAssociationWizard.ASSOCIATION_CADINALITY, Association.MANY_TO_ONE); - }else if( e.getSource() == cardinalityButtons[1]){ - getWizardDataModel().put(NewAssociationWizard.ASSOCIATION_CADINALITY, Association.ONE_TO_MANY ); - }else if( e.getSource() == cardinalityButtons[2]){ - getWizardDataModel().put(NewAssociationWizard.ASSOCIATION_CADINALITY, Association.ONE_TO_ONE); - }else{ - getWizardDataModel().put(NewAssociationWizard.ASSOCIATION_CADINALITY, Association.MANY_TO_MANY); - } - CardinalityPage.this.setPageComplete(true); - - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/CascadeDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/CascadeDialog.java deleted file mode 100644 index d95ca10b56..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/CascadeDialog.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.wizards.gen; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TrayDialog; -import org.eclipse.jpt.jpa.gen.internal.AssociationRole; -import org.eclipse.jpt.jpa.gen.internal.util.StringUtil; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - -/** - * Simple dialog allows user to set the cascade property of an associationRole. - * The value of cascade can be "all", or any combination of other selections. - * - */ -public class CascadeDialog extends TrayDialog { - - private static String[] ALL_CASCADES = new String[] {TagNames.ALL_CASCADE, TagNames.PERSIST_CASCADE, TagNames.MERGE_CASCADE - , TagNames.REMOVE_CASCADE, TagNames.REFRESH_CASCADE}; - - private static String[] ALL_CASCADES_LABELS - = new String[] { "&all", //$NON-NLS-1$ - "&persist", //$NON-NLS-1$ - "&merge", //$NON-NLS-1$ - "&remove", //$NON-NLS-1$ - "r&efresh"}; //$NON-NLS-1$ - - - private Button[] allButtons = new Button[ALL_CASCADES.length]; - - private AssociationRole associationRole; - private List<String> cascades; - - protected CascadeDialog(Shell parentShell) { - super(parentShell); - } - - public static CascadeDialog create(AssociationRole role) { - CascadeDialog dlg = new CascadeDialog(Display.getDefault().getActiveShell() ); - dlg.setAssociationRole(role); - return dlg; - } - - /* - * (non-Javadoc) Method declared on Window. - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(JptUiEntityGenMessages.selectCascadeDlgTitle); - this.getHelpSystem().setHelp(newShell, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_SELECT_CASCADE); - } - - private void setAssociationRole(AssociationRole role) { - this.associationRole = role; - List<String> list = StringUtil.strToList(associationRole.getCascade(), ',', true/*trim*/); //role.getCascade() contains the comma separed cascades (see below) - if (list == null) { - list = Collections.emptyList(); - } - cascades = list; - - } - - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - protected Control createDialogArea(Composite parent) { - Composite container = (Composite) super.createDialogArea(parent); - createCascadeTypesGroup(container); - Dialog.applyDialogFont(container); - return container; - } - - private void createCascadeTypesGroup(Composite parent) { - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout()); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = 275; - group.setLayoutData(gd); - group.setText(JptUiEntityGenMessages.cascade); - - for( int i=0; i< ALL_CASCADES.length; i ++ ){ - Button checkbox = new Button(group, SWT.CHECK); - checkbox.setText( ALL_CASCADES_LABELS[i] ); - checkbox.setSelection( isInList(ALL_CASCADES[i]) ); //$NON-NLS-1$ - checkbox.setData(ALL_CASCADES[i]); - allButtons[i] = checkbox; - /*if <code>all</code> is selected then deselect all others*/ - checkbox.addSelectionListener( new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - Button b = (Button)e.getSource(); - if( b.getSelection() ){ - if( b == allButtons[0] ){ - for( Button btn : allButtons ){ - if( btn != e.getSource() ) btn.setSelection(false); - } - }else{ - allButtons[0].setSelection(false); - } - } - } - }); - } - } - - protected void okPressed() { - StringBuilder builder = new StringBuilder(); - for( Button b : allButtons ){ - if( b.getSelection() ){ - if( builder.length()>0 ){ - builder.append( ','); - } - builder.append( b.getData() ); - } - } - this.associationRole.setCascade( builder.toString() ); - super.okPressed(); - } - - private boolean isInList(String cascade) { - for( String s : cascades ){ - if( s.equals(cascade )){ - return true; - } - } - return false; - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } - -} - -class TagNames -{ - public static final String BASIC_TAG = "basic"; - public static final String CASCADE_TAG = "cascade"; - public static final String COLUMN_TAG = "column"; - public static final String EMBEDDED_TAG = "embedded"; - public static final String EMBEDDED_ID_TAG = "embedded-id"; - public static final String GENERATED_VALUE_TAG = "generated-value"; - public static final String ID_TAG = "id"; - public static final String ID_CLASS_TAG = "id"; - public static final String JOIN_COLUMN_TAG = "join-column"; - public static final String INVERSE_JOIN_COLUMN_TAG = "inverse-join-column"; - public static final String LOB_TAG = "lob"; - public static final String MANY_TO_MANY_TAG = "many-to-many"; - public static final String MANY_TO_ONE_TAG = "many-to-one"; - public static final String MAPPED_BY_TAG = "mapped-by"; - public static final String ONE_TO_MANY_TAG = "one-to-many"; - public static final String ONE_TO_ONE_TAG = "one-to-one"; - public static final String PK_JOIN_COLUMN_TAG = "primary-key-join-column"; - public static final String TABLE_TAG = "table"; - public static final String VERSION_TAG = "version"; - public static final String JOIN_TABLE_TAG = "join-table"; - - /*cascade tags*/ - public static final String ALL_CASCADE = "all"; - public static final String PERSIST_CASCADE = "persist"; - public static final String MERGE_CASCADE = "merge"; - public static final String REMOVE_CASCADE = "remove"; - public static final String REFRESH_CASCADE = "refresh"; -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/ColumnGenPanel.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/ColumnGenPanel.java deleted file mode 100644 index 93c19cd872..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/ColumnGenPanel.java +++ /dev/null @@ -1,360 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.jpa.gen.internal.ORMGenColumn; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Text; - -/** - * The panel used in the <code>TablesAndColumnsPage</code> wizard page - * to edit the column generation properties. - * An instance of this class is created by the <code>ORMGenWizard</code> - * implementation. - - */ -public class ColumnGenPanel -{ - WizardPage wizardPage ; - Composite parent; //parent control with grid layout - int columns; //total columns in the parent composite - - ORMGenCustomizer customizer; - - private ORMGenColumn mColumn; - private boolean mPanelInited; - private boolean mIsUpdatingControls; - - private Group columnMappingGroup; - private Button mGeneratedCheckbox; - private Text mPropNameField; - private Combo mMappingKindCombo; - private Combo mPropTypeCombo; - private Button mUpdateableCheckBox; - private Button mInsertableCheckBox; - - private Group domainClassGroup ; - private ScopePanel mPropGetScopePanel; - private ScopePanel mPropSetScopePanel; - - public ColumnGenPanel(Composite parent, int columns, ORMGenCustomizer customizer, WizardPage wizardPage ) { - this.wizardPage = wizardPage; - this.customizer = customizer; - this.parent =parent; - this.columns = columns; - - initPanel(); - } - /** - * Changes the table edited by the panel. - * This is supposed to update the panel editing controls - * using the column values. - */ - public void setColumn(ORMGenColumn column) { - mColumn = column; - - /*lazy init panel because it uses mColumn*/ - if (!mPanelInited) { - initPanel(); - mPanelInited = true; - } - - updateControls(); - } - private void updateControls() { - if (mIsUpdatingControls) { - return; - } - - mIsUpdatingControls = true; - boolean isGenerated = mColumn.isGenerated(); - mGeneratedCheckbox.setSelection( isGenerated); - mGeneratedCheckbox.setEnabled(true); - enableControls(isGenerated); - try { - mPropNameField.setText(mColumn.getPropertyName()); - - mPropTypeCombo.setText( mColumn.getPropertyType()); - - mMappingKindCombo.setText( mColumn.getMappingKind()); - - mUpdateableCheckBox.setSelection( mColumn.isUpdateable()); - - mInsertableCheckBox.setSelection(mColumn.isInsertable()); - - mPropGetScopePanel.enableComponents(isGenerated); - mPropGetScopePanel.setScope(mColumn.getPropertyGetScope()); - - mPropSetScopePanel.enableComponents( isGenerated ); - mPropSetScopePanel.setScope(mColumn.getPropertySetScope()); - - if( mColumn.isPartOfCompositePrimaryKey()){ - enableControls(false); - mPropNameField.setEnabled(true); - mGeneratedCheckbox.setEnabled(false); - } - - } catch (Exception e) { - JptJpaUiPlugin.log(e); - } - - mIsUpdatingControls = false; - } - private void enableControls(boolean isGenerated) { - Control[] controls = this.domainClassGroup.getChildren(); - for( Control c: controls){ - c.setEnabled( isGenerated ); - } - - controls = this.columnMappingGroup.getChildren(); - for( Control c: controls){ - c.setEnabled( isGenerated ); - } - } - /** - * Initializes the panel by adding the editing controls. - * @param columns - * @param parent - */ - protected void initPanel() { - createControls(parent, columns); - this.mPanelInited = true; - } - - //------------------------------------------- - //----- ScopePanel class -------------------- - //------------------------------------------- - /** - * A panel containing 3 radios (public, protected, private) - */ - private class ScopePanel - { - private Button mPublicRadio; - private Button mProtectedRadio; - private Button mPrivateRadio; - - public ScopePanel(Composite comp, SelectionListener listener) { - //super(3, 20/*hspacing*/, 0/*vspacing*/); - - Composite radioGroup = new Composite( comp, SWT.NONE); - radioGroup.setLayout(new GridLayout(3, true)); - GridData gd = new GridData(); - gd.horizontalSpan = 3; - radioGroup.setLayoutData(gd); - - /*string not localized intentionally, they are used as the actual - * scope value (see getText() usage)*/ - mPublicRadio = new Button( radioGroup, SWT.RADIO ); - mPublicRadio.setText( "public"); - mPublicRadio.setLayoutData(new GridData()); - mProtectedRadio = new Button( radioGroup, SWT.RADIO ); - mProtectedRadio.setText("protected"); - mProtectedRadio.setLayoutData(new GridData()); - mPrivateRadio = new Button(radioGroup, SWT.RADIO ); - mPrivateRadio.setText( "private"); - mPrivateRadio.setLayoutData(new GridData()); - - mPublicRadio.addSelectionListener(listener); - mProtectedRadio.addSelectionListener(listener); - mPrivateRadio.addSelectionListener(listener); - - } - public void enableComponents(boolean b) { - mPublicRadio.setEnabled(b); - mProtectedRadio.setEnabled(b); - mPrivateRadio.setEnabled(b); - } - /** - * Returns the currently selected scope. - */ - public String getScope() { - Button radio = null; - if (mPublicRadio.getSelection()) { - radio = mPublicRadio; - } else if (mProtectedRadio.getSelection() ) { - radio = mProtectedRadio; - } else if (mPrivateRadio.getSelection() ) { - radio = mPrivateRadio; - } - return radio != null ? radio.getText() : null; - } - public void setScope(String scope) { - mPublicRadio.setSelection(false); - mProtectedRadio.setSelection(false); - mPrivateRadio.setSelection(false); - if( scope == null ) - return; - if (scope.equals(ORMGenColumn.PUBLIC_SCOPE)) { - mPublicRadio.setSelection(true); - } else if (scope.equals(ORMGenColumn.PROTECTED_SCOPE)) { - mProtectedRadio.setSelection(true); - } else if (scope.equals(ORMGenColumn.PRIVATE_SCOPE)) { - mPrivateRadio.setSelection(true); - } - } - } - - //------------------------------------------- - //----- private methods --------------------- - //------------------------------------------- - private void createControls(Composite composite, int columns) { - mGeneratedCheckbox = new Button(composite, SWT.CHECK); - mGeneratedCheckbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_genProp); - mGeneratedCheckbox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!mIsUpdatingControls) { - mColumn.setGenerated(mGeneratedCheckbox.getSelection() ); - updateControls(); - } - }}); - SWTUtil.fillColumns(mGeneratedCheckbox, columns); - - columnMappingGroup = new Group( composite, SWT.NONE); - columnMappingGroup.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_colMapping); - columnMappingGroup.setLayout(new GridLayout(columns, false)); - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - layoutData.horizontalIndent = 20 ; - columnMappingGroup.setLayoutData(layoutData); - - SWTUtil.createLabel(columnMappingGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_propName ); - mPropNameField = new Text(columnMappingGroup, SWT.BORDER | SWT.SINGLE ); - mPropNameField.addModifyListener(new ModifyListener(){ - @SuppressWarnings("restriction") - public void modifyText(ModifyEvent e) { - if (!mIsUpdatingControls) { - String fldName = mPropNameField.getText(); - IStatus status = JavaConventions.validateIdentifier( fldName, - JavaCore.VERSION_1_3, JavaCore.VERSION_1_3 ); - if( !status.matches(IStatus.ERROR)){ - mColumn.setPropertyName(fldName); - wizardPage.setErrorMessage(null); - }else{ - wizardPage.setErrorMessage(status.getMessage()); - } - } - } - }); - SWTUtil.fillColumns(mPropNameField ,3); - - SWTUtil.createLabel(columnMappingGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_propType ); - mPropTypeCombo = new Combo(columnMappingGroup, SWT.SINGLE | SWT.READ_ONLY); - mPropTypeCombo.setItems( this.customizer.getAllPropertyTypes()); - mPropTypeCombo.addModifyListener( new ModifyListener(){ - public void modifyText(ModifyEvent e) { - if (!mIsUpdatingControls) { - mColumn.setPropertyType(mPropTypeCombo.getText()); - } - } - }); - SWTUtil.fillColumns(mPropTypeCombo,3); - - SWTUtil.createLabel(columnMappingGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_mapKind ); - mMappingKindCombo = new Combo(columnMappingGroup, SWT.SINGLE | SWT.READ_ONLY); - mMappingKindCombo.setItems( this.customizer.getAllMappingKinds()); - mMappingKindCombo.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!mIsUpdatingControls) { - mColumn.setMappingKind((String)mMappingKindCombo.getText()); - } - - }}); - SWTUtil.fillColumns(mMappingKindCombo ,3); - - mUpdateableCheckBox = new Button(columnMappingGroup, SWT.CHECK); - mUpdateableCheckBox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_colUpdateable); - mUpdateableCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!mIsUpdatingControls) { - mColumn.setUpdateable(mUpdateableCheckBox.getSelection() ); - } - }}); - SWTUtil.fillColumns(mUpdateableCheckBox ,4); - - mInsertableCheckBox = new Button(columnMappingGroup, SWT.CHECK); - mInsertableCheckBox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_colInsertable); - mInsertableCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!mIsUpdatingControls) { - mColumn.setInsertable(mInsertableCheckBox.getSelection()); - } - }}); - SWTUtil.fillColumns(mInsertableCheckBox ,4); - - SWTUtil.createLabel(composite, 4,""); - - createJavaBeanPropertyControls(composite, columns); - } - - void createJavaBeanPropertyControls(Composite composite, int columns){ - //Java class generation properties - domainClassGroup = new Group(composite, SWT.NONE); - domainClassGroup.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_beanProp ); - domainClassGroup.setLayout(new GridLayout(columns, false)); - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - layoutData.horizontalIndent = 20; - domainClassGroup.setLayoutData(layoutData); - - SWTUtil.createLabel(domainClassGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_getterScope ); - mPropGetScopePanel = new ScopePanel(domainClassGroup, new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - if (!mIsUpdatingControls) { - if( ((Button)e.getSource()).getSelection() ) - mColumn.setPropertyGetScope(mPropGetScopePanel.getScope()); - } - - }}); - - SWTUtil.createLabel(domainClassGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_colPanel_setterScope ); - mPropSetScopePanel = new ScopePanel(domainClassGroup, new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - if (!mIsUpdatingControls) { - if( ((Button)e.getSource()).getSelection() ) - mColumn.setPropertySetScope(mPropSetScopePanel.getScope()); - } - }}); - - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/DatabaseGroup.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/DatabaseGroup.java deleted file mode 100644 index 8be4218b9b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/DatabaseGroup.java +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.EventListener; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.SortedSet; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.wizard.IWizardContainer; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.db.ConnectionAdapter; -import org.eclipse.jpt.jpa.db.ConnectionListener; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.JptJpaDbPlugin; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.db.ui.internal.DTPUiTools; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -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.Display; -import org.eclipse.swt.widgets.Label; - -/** - * A composite used to connect to database, includes following UI controls: - * - connection combo-box - * - schema combo-box - * - add connection button - * - reconnect button - */ -public class DatabaseGroup -{ - private final JpaProject jpaProject; - private final Set<Listener> listeners = Collections.synchronizedSet(new HashSet<Listener>()); - - // these are kept in synch with the selection - ConnectionProfile selectedConnectionProfile; - private Schema selectedSchema; - - private final Combo connectionComboBox; - - private final Combo schemaComboBox; - - private final Button reconnectButton; - - private final ConnectionListener connectionListener; - - private IWizardContainer wizardContainer; - - protected final ResourceManager resourceManager; - - // ********** construction ********** - - DatabaseGroup(IWizardContainer wizardContainer, JpaProject jpaProject, Composite parent, ResourceManager resourceManager, int widthHint) { - super(); - this.wizardContainer = wizardContainer; - this.jpaProject = jpaProject; - this.resourceManager = resourceManager; - - // connection combo-box - this.buildLabel(parent, 1, JptUiEntityGenMessages.connection); - this.connectionComboBox = this.buildComboBox(parent, widthHint, this.buildConnectionComboBoxSelectionListener()); - - // add connection button - Button addConnectionButton = this.buildButton(parent, JptUiEntityGenMessages.addConnectionLink, ImageRepository.getAddConnectionButtonImage(this.resourceManager), this.buildAddConnectionLinkSelectionListener()); - GridData data = new GridData(); - addConnectionButton.setLayoutData(data); - - - // A composite holds the reconnect button & text - this.buildLabel(parent, 1, ""); //$NON-NLS-1$ - Composite comp = new Composite( parent , SWT.NONE ); - GridData gd = new GridData(); - gd.grabExcessHorizontalSpace = true ; - gd.horizontalSpan = 2; - comp.setLayoutData( gd ); - GridLayout gl = new GridLayout(2, false); - // Make the reconnect button to be closer to the connection combo. - gl.marginTop = -5; - comp.setLayout(gl); - this.reconnectButton = this.buildButton(comp, JptUiEntityGenMessages.connectLink, ImageRepository.getReconnectButtonImage(this.resourceManager), this.buildReconnectLinkSelectionListener()); - this.buildLabel(comp, 1, JptUiEntityGenMessages.schemaInfo); - - // schema combo-box - this.buildLabel(parent, 1, JptUiEntityGenMessages.schema); - this.schemaComboBox = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(SWT.BEGINNING, SWT.CENTER, true, false); - data.horizontalAlignment = SWT.FILL; - data.horizontalSpan = 1; - data.grabExcessHorizontalSpace = true ; - this.schemaComboBox.setLayoutData(data); - this.schemaComboBox.addSelectionListener(this.buildSchemaComboBoxSelectionListener()); - // filler - new Label(parent, SWT.NULL); - - this.connectionListener = this.buildConnectionListener(); - } - - - public void init() - { - // initialize state, based on JPA project - this.selectedConnectionProfile = this.getJpaProjectConnectionProfile(); - this.selectedSchema = this.getDefaultSchema(); - - if (this.selectedSchema != null) { - this.fireSchemaChanged(this.selectedSchema); - } - if (this.selectedConnectionProfile != null) { - this.selectedConnectionProfile.addConnectionListener(this.connectionListener); - this.fireConnectionProfileChanged(this.selectedConnectionProfile); - } - - this.updateConnectionComboBox(); - this.updateSchemaComboBox(); - this.updateReconnectLink(); - - } - // ********** intra-wizard methods ********** - - Schema getSelectedSchema() { - return this.selectedSchema; - } - - void dispose() { - if (this.selectedConnectionProfile != null) { - this.selectedConnectionProfile.removeConnectionListener(this.connectionListener); - } - } - - - // ********** internal methods ********** - - /** - * this can return null; - * called at start-up and when the selected connection profile changes - */ - private ConnectionProfile getJpaProjectConnectionProfile() { - return this.jpaProject.getConnectionProfile(); - } - - /** - * this can return null; - * called at start-up and when the selected connection profile changes - */ - private Schema getDefaultSchema() { - return (this.selectedConnectionProfile == this.getJpaProjectConnectionProfile()) ? - jpaProject.getDefaultDbSchema() : null; - } - - /** - * the connection combo-box is updated at start-up and when the user - * adds a connection profile - */ - private void updateConnectionComboBox() { - this.connectionComboBox.removeAll(); - for (String cpName : this.buildSortedConnectionProfileNames()) { - this.connectionComboBox.add(cpName); - } - if (this.selectedConnectionProfile != null) { - this.connectionComboBox.select(this.connectionComboBox.indexOf(this.selectedConnectionProfile.getName())); - } - } - - private SortedSet<String> buildSortedConnectionProfileNames() { - return CollectionTools.sortedSet(JptJpaDbPlugin.getConnectionProfileFactory().getConnectionProfileNames()); - } - - /** - * called at start-up and when the selected connection profile changes - */ - private void updateReconnectLink() { - this.reconnectButton.setEnabled(this.reconnectLinkCanBeEnabled()); - } - - private boolean reconnectLinkCanBeEnabled() { - return (this.selectedConnectionProfile != null) && !(this.selectedConnectionProfile.isActive()); - } - - /** - * the schema combo-box is updated at start-up and - * when the selected connection profile changes - */ - private void updateSchemaComboBox() { - this.schemaComboBox.removeAll(); - for (String name : this.getSchemaNames()) { - this.schemaComboBox.add(name); - } - // the current schema *should* be in the current connection profile - if (this.selectedSchema != null) { - this.schemaComboBox.select(this.schemaComboBox.indexOf(this.selectedSchema.getName())); - } - } - - private Iterable<String> getSchemaNames() { - SchemaContainer sc = this.jpaProject.getDefaultDbSchemaContainer(); - // use schema *names* since the combo-box is read-only - return (sc != null) ? sc.getSortedSchemaNames() : EmptyIterable.<String>instance(); - } - - /** - * If the specified name matches the name of the JPA project's - * connection profile, return it; otherwise, build a new connection - * profile. - */ - private ConnectionProfile checkJpaProjectConnectionProfile(String cpName) { - ConnectionProfile cp = this.getJpaProjectConnectionProfile(); - if ((cp != null) && cp.getName().equals(cpName)) { - return cp; - } - return this.buildConnectionProfile(cpName); - } - - private ConnectionProfile buildConnectionProfile(String name) { - return JptJpaDbPlugin.getConnectionProfileFactory().buildConnectionProfile(name); - } - - - // ********** listener callbacks ********** - - void selectedConnectionChanged() { - String text = this.connectionComboBox.getText(); - if (text.length() == 0) { - if (this.selectedConnectionProfile == null) { - return; // no change - } - this.selectedConnectionProfile.removeConnectionListener(this.connectionListener); - this.selectedConnectionProfile = null; - } else { - if (this.selectedConnectionProfile == null) { - this.selectedConnectionProfile = this.checkJpaProjectConnectionProfile(text); - } else { - if (text.equals(this.selectedConnectionProfile.getName())) { - return; // no change - } - this.selectedConnectionProfile.removeConnectionListener(this.connectionListener); - this.selectedConnectionProfile = this.checkJpaProjectConnectionProfile(text); - } - this.selectedConnectionProfile.addConnectionListener(this.connectionListener); - } - this.fireConnectionProfileChanged(this.selectedConnectionProfile); - this.connectionChanged(); - } - - void selectedSchemaChanged() { - Schema old = this.selectedSchema; - this.selectedSchema = this.jpaProject.getDefaultDbSchemaContainer().getSchemaNamed(this.schemaComboBox.getText()); - if (this.selectedSchema != old) { - fireSchemaChanged(this.selectedSchema); - } - } - - /** - * Open the DTP New Connection Profile wizard. - * If the user creates a new connection profile, start using it and - * connect it - */ - void addConnection() { - String addedProfileName = DTPUiTools.createNewConnectionProfile(); - if (addedProfileName == null) { - return; // user pressed "Cancel" - } - if (this.selectedConnectionProfile != null) { - this.selectedConnectionProfile.removeConnectionListener(this.connectionListener); - } - this.selectedConnectionProfile = this.buildConnectionProfile(addedProfileName); - this.selectedConnectionProfile.addConnectionListener(this.connectionListener); - this.updateConnectionComboBox(); - this.selectedConnectionProfile.connect(); - // everything else should be synchronized when we get the resulting open event - this.fireConnectionProfileChanged(this.selectedConnectionProfile); - this.updateSchemaComboBox(); - } - - void reconnect() { - try { - wizardContainer.run(true, true, new IRunnableWithProgress(){ - public void run( final IProgressMonitor monitor ) - throws InvocationTargetException, InterruptedException - { - monitor.beginTask(JptUiEntityGenMessages.connectingToDatabase, 10); - final SynchronizedBoolean finished = new SynchronizedBoolean(false); - Thread t = new Thread(){ - @Override - public void run() { - try { - DatabaseGroup.this.selectedConnectionProfile.connect(); - } catch (Exception ex) { - JptJpaUiPlugin.log(ex); - } finally { - finished.setTrue(); - } - } - }; - t.start(); - while (finished.isFalse()){ - Thread.sleep(1000); - monitor.worked(1); - } - // everything should be synchronized when we get the resulting open event - monitor.done(); - } - }); - } catch (Exception e) { - JptJpaUiPlugin.log(e); - } - wizardContainer.updateButtons(); - } - - /** - * called when - * - the user selects a new connection - * - the connection was opened - * - the connection was closed (never happens?) - * we need to update the schema stuff and the reconnect link - */ - void connectionChanged() { - Schema old = this.selectedSchema; - this.selectedSchema = this.getDefaultSchema(); - if (this.selectedSchema != old) { - this.fireSchemaChanged(this.selectedSchema); - } - this.updateSchemaComboBox(); - this.updateReconnectLink(); - } - - - // ********** listeners ********** - - private SelectionListener buildConnectionComboBoxSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - // nothing special for "default" (double-click?) - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - DatabaseGroup.this.selectedConnectionChanged(); - } - @Override - public String toString() { - return "DatabaseConnectionWizardPage connection combo-box selection listener"; //$NON-NLS-1$ - } - }; - } - - private SelectionListener buildSchemaComboBoxSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - // nothing special for "default" (double-click?) - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - DatabaseGroup.this.selectedSchemaChanged(); - } - @Override - public String toString() { - return "DatabaseConnectionWizardPage schema combo-box selection listener"; //$NON-NLS-1$ - } - }; - } - - private SelectionListener buildAddConnectionLinkSelectionListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - DatabaseGroup.this.addConnection(); - } - @Override - public String toString() { - return "DatabaseConnectionWizardPage add connection link selection listener"; //$NON-NLS-1$ - } - }; - } - - private SelectionListener buildReconnectLinkSelectionListener() { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - DatabaseGroup.this.reconnect(); - } - @Override - public String toString() { - return "DatabaseConnectionWizardPage reconnect link selection listener"; //$NON-NLS-1$ - } - }; - } - - private ConnectionListener buildConnectionListener() { - return new ConnectionAdapter() { - @Override - public void opened(ConnectionProfile cp) { - this.connectionChanged(); - } - @Override // this probably won't ever get called... - public void closed(ConnectionProfile cp) { - this.connectionChanged(); - } - private void connectionChanged() { - Display.getDefault().asyncExec( - new Runnable() { - public void run() { - DatabaseGroup.this.connectionChanged(); - } - } - ); - } - @Override - public String toString() { - return "DatabaseConnectionWizardPage connection listener"; //$NON-NLS-1$ - } - }; - } - - - // ********** listeners ********** - - public void addListener(Listener listener) { - if ( ! this.listeners.add(listener)) { - throw new IllegalArgumentException("duplicate listener: " + listener); //$NON-NLS-1$ - } - } - - public void removeListener(Listener listener) { - if ( ! this.listeners.remove(listener)) { - throw new IllegalArgumentException("missing listener: " + listener); //$NON-NLS-1$ - } - } - - private Iterator<Listener> listeners() { - return new CloneIterator<Listener>(this.listeners); - } - - void fireConnectionProfileChanged(ConnectionProfile connectionProfile) { - for (Iterator<Listener> stream = this.listeners(); stream.hasNext(); ) { - stream.next().selectedConnectionProfileChanged(connectionProfile); - } - } - - void fireSchemaChanged(Schema schema) { - for (Iterator<Listener> stream = this.listeners(); stream.hasNext(); ) { - stream.next().selectedSchemaChanged(schema); - } - } - - // ********** UI components ********** - - /** - * build and return a label - */ - private Label buildLabel(Composite parent, int span, String text) { - Label label = new Label(parent, SWT.NONE); - label.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - label.setLayoutData(gd); - return label; - } - - /** - * build and return a combo-box - */ - private Combo buildComboBox(Composite parent, int widthHint, SelectionListener listener) { - Combo combo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); - combo.addSelectionListener(listener); - GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); - //data.grabExcessHorizontalSpace = true ; - data.widthHint = widthHint; - combo.setLayoutData(data); - return combo; - } - - /** - * build and return a link - */ - private Button buildButton(Composite parent, String toolTipText, Image image, SelectionListener listener) { - Button button = new Button(parent, SWT.NONE); - GridData data = new GridData(GridData.END, GridData.CENTER, false, false); - data.horizontalSpan = 1; - button.setLayoutData(data); - button.setImage( image ); - button.setToolTipText( toolTipText); - button.addSelectionListener(listener); - return button; - } - - // ********** listener interface ********** - - /** - * Allows clients to listen for changes to the selected connection profile - * and schema. - */ - public interface Listener extends EventListener - { - void selectedConnectionProfileChanged(ConnectionProfile connectionProfile); - void selectedSchemaChanged(Schema schema); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/DefaultTableGenerationWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/DefaultTableGenerationWizardPage.java deleted file mode 100644 index 65d529b782..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/DefaultTableGenerationWizardPage.java +++ /dev/null @@ -1,327 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.List; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; -import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; -import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter; -import org.eclipse.jdt.ui.JavaElementComparator; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jdt.ui.StandardJavaElementContentProvider; -import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.gen.internal.ORMGenTable; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - -/** - * A wizard page allowing the entry of the default table generation - * properties (Java classes package, base class, etc). - * These properties apply to all tables unless explicitly overridden (in the table generation page). - * - * @author Danny Ju - */ -@SuppressWarnings("restriction") -public class DefaultTableGenerationWizardPage extends NewTypeWizardPage { - - private JpaProject jpaProject; - - /*the instance used to get/set the default properties.*/ - private ORMGenTable defaultsTable; - - private ORMGenCustomizer customizer; - - private TableGenPanel defaultTableGenPanel ; - - protected DefaultTableGenerationWizardPage(JpaProject jpaProject) { - super(true, "DefaultTableGenerationWizardPage"); //$NON-NLS-1$ - this.jpaProject = jpaProject; - setTitle(JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_title); - setDescription( JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_desc); - } - - - // -------- Initialization --------- - /** - * The wizard owning this page is responsible for calling this method with the - * current selection. The selection is used to initialize the fields of the wizard - * page. - * - * @param selection used to initialize the fields - */ - void init(IStructuredSelection selection) { - IJavaElement jelem = null; - if ( selection!=null && selection.getFirstElement() instanceof IJavaElement ) { - jelem = (IJavaElement) selection.getFirstElement(); - }else{ - jelem = this.jpaProject.getJavaProject(); - } - if( jelem !=null ){ - initContainerPage(jelem); - initTypePage(jelem); - } - - } - - public void createControl(Composite parent) { - initializeDialogUnits(parent); - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 4 ; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_CUSTOMIZE_DEFAULT_ENTITY_GENERATION); - - //Create entity access, collection type, etc - defaultTableGenPanel = new TableGenPanel(composite, 4, true, this); - - createDomainJavaClassesPropertiesGroup(composite, 4); - setControl(composite); - - - this.setPageComplete( true ); - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - ORMGenCustomizer customizer = getCustomizer(); - //If user changed the connection or schema - if ( this.customizer != customizer ) { - this.customizer = customizer; - defaultsTable=customizer.createGenTable(null); - defaultTableGenPanel.setORMGenTable(defaultsTable); - //set the super class and implemented interfaces value - String baseClass = defaultsTable.getExtends() == null ?"" : defaultsTable.getExtends(); - setSuperClass(baseClass, true); - setSuperInterfaces(defaultsTable.getImplements(), true); - IPackageFragmentRoot root = getSourceFolder( defaultsTable.getSourceFolder()); - String initPackageName = this.getPackageText(); - if( initPackageName.length()==0 ){ - setPackageName( root, defaultsTable.getPackage() ); - } - setPackageFragmentRoot(root, true/*canBeModified*/); - } - } - } - - //search for the source folder with the given name or return the first - //source folder if not found. - private IPackageFragmentRoot getSourceFolder(String srcFolder) { - IPackageFragmentRoot packageFragmentRoot = null; - srcFolder = '/' + srcFolder; - IJavaProject javaProject = this.jpaProject.getJavaProject(); - - for (IPackageFragmentRoot root : JDTTools.getJavaSourceFolders(javaProject)) { - //Save the first source root in case we don't find one that matches the saved value - if (packageFragmentRoot == null) { - packageFragmentRoot = root; - } - //check for alternative source root that matches the saved value - if (root.getPath().toString().equals(srcFolder)){ - packageFragmentRoot = root; - break; - } - } - return packageFragmentRoot; - } - - private void setPackageName(IPackageFragmentRoot packageFragmentRoot, String packageName) { - if( packageName == null || packageName.length() == 0 || packageFragmentRoot==null) { - return; - } - IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(packageName); - setPackageFragment(packageFragment, true/*canBeModified*/); - } - - - protected void createDomainJavaClassesPropertiesGroup(Composite composite, int columns) { - Group parent = new Group( composite, SWT.NONE); - parent.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_domainJavaClass); - parent.setLayout(new GridLayout( columns, false)); - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = true; - parent.setLayoutData(layoutData); - - //default Java package name only available for default table generation - createContainerControls(parent, columns); - createPackageControls(parent, columns); - createSuperClassControls(parent, columns); - createSuperInterfacesControls(parent, columns); - } - - @Override - protected IStatus packageChanged() { - IStatus status = super.packageChanged(); - IPackageFragment packageFragment = getPackageFragment(); - //String srcFolder = packageFragment.getPath().toPortableString(); - if (defaultsTable != null && !status.matches(IStatus.ERROR)) { - defaultsTable.setPackage(packageFragment.getElementName()); - } - return status; - } - - @Override - protected IStatus superClassChanged() { - IStatus status = super.superClassChanged(); - String baseClass = getSuperClass(); - if (baseClass != null && defaultsTable != null && !status.matches(IStatus.ERROR)) { - String oldBaseClass = defaultsTable.getExtends(); - if ( !baseClass.equals(oldBaseClass)) { - defaultsTable.setExtends(baseClass); - } - } - return status; - } - @Override - protected IStatus containerChanged() { - IStatus status = super.containerChanged(); - String srcFolder = getPackageFragmentRootText(); - if( !status.matches(IStatus.ERROR) ){ - if (defaultsTable != null ) { - defaultsTable.setSourceFolder( srcFolder ); - } - } - return status; - } - - /** Override to allow select source folder in current project only - * @see org.eclipse.jdt.ui.wizards.NewContainerWizardPage#chooseContainer() - */ - @Override - protected IPackageFragmentRoot chooseContainer() { - Class<?>[] acceptedClasses = new Class[] { IPackageFragmentRoot.class, IJavaProject.class }; - TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) { - @Override - public boolean isSelectedValid(Object element) { - try { - if (element instanceof IJavaProject) { - IJavaProject jproject= (IJavaProject)element; - IPath path= jproject.getProject().getFullPath(); - return (jproject.findPackageFragmentRoot(path) != null); - } else if (element instanceof IPackageFragmentRoot) { - return JDTTools.packageFragmentRootIsSourceFolder((IPackageFragmentRoot) element); - } - return true; - } catch (JavaModelException e) { - JptJpaUiPlugin.log(e); // just log, no UI in validation - } - return false; - } - }; - - acceptedClasses= new Class[] { IJavaModel.class, IPackageFragmentRoot.class, IJavaProject.class }; - ViewerFilter filter= new TypedViewerFilter(acceptedClasses) { - @Override - public boolean select(Viewer viewer, Object parent, Object element) { - if (element instanceof IPackageFragmentRoot) { - return JDTTools.packageFragmentRootIsSourceFolder((IPackageFragmentRoot) element); - } - return super.select(viewer, parent, element); - } - }; - - StandardJavaElementContentProvider provider= new StandardJavaElementContentProvider(); - ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); - ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, provider); - dialog.setValidator(validator); - dialog.setComparator(new JavaElementComparator()); - dialog.setTitle(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title); - dialog.setMessage(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description); - dialog.addFilter(filter); - dialog.setInput(jpaProject.getJavaProject()); - dialog.setInitialSelection(getPackageFragmentRoot()); - dialog.setHelpAvailable(false); - - if (dialog.open() == Window.OK) { - Object element= dialog.getFirstResult(); - if (element instanceof IJavaProject) { - IJavaProject jproject= (IJavaProject)element; - return jproject.getPackageFragmentRoot(jproject.getProject()); - } else if (element instanceof IPackageFragmentRoot) { - return (IPackageFragmentRoot)element; - } - return null; - } - return null; - } - - @Override - protected void handleFieldChanged(String fieldName) { - super.handleFieldChanged(fieldName); - if (this.fContainerStatus.matches(IStatus.ERROR)) { - updateStatus(fContainerStatus); - }else if( ! this.fPackageStatus.matches(IStatus.OK) ) { - updateStatus(fPackageStatus); - } else if (this.fSuperClassStatus.matches(IStatus.ERROR)) { - updateStatus(fSuperClassStatus); - } else { - updateStatus(Status.OK_STATUS); - } - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected IStatus superInterfacesChanged() { - IStatus ret = super.superInterfacesChanged(); - if ( ret.isOK() ) { - List interfaces = getSuperInterfaces(); - if(defaultsTable!=null) - defaultsTable.setImplements(interfaces); - } - return ret; - } - - private ORMGenCustomizer getCustomizer() { - GenerateEntitiesFromSchemaWizard wizard = (GenerateEntitiesFromSchemaWizard) this.getWizard(); - return wizard.getCustomizer(); - } - - @Override - public final void performHelp() { - this.getHelpSystem().displayHelp( GenerateEntitiesFromSchemaWizard.HELP_CONTEXT_ID ); - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } -} - diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java deleted file mode 100644 index f74dcfb7f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java +++ /dev/null @@ -1,541 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.io.File; -import java.io.IOException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceRuleFactory; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.resource.LocalResourceManager; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jpt.common.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.jpa.core.EntityGeneratorDatabaseAnnotationNameBuilder; -import org.eclipse.jpt.jpa.core.JpaPlatform; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.ForeignKey; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.gen.internal.BaseEntityGenCustomizer; -import org.eclipse.jpt.jpa.gen.internal.DatabaseAnnotationNameBuilder; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.gen.internal.ORMGenTable; -import org.eclipse.jpt.jpa.gen.internal.PackageGenerator; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -public class GenerateEntitiesFromSchemaWizard extends Wizard - implements INewWizard { - - public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$ - - private static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG"; //$NON-NLS-1$ - - private JpaProject jpaProject; - - private IStructuredSelection selection; - - private ORMGenCustomizer customizer = null; - - private PromptJPAProjectWizardPage projectPage; - - private TablesSelectorWizardPage tablesSelectorPage; - - private TableAssociationsWizardPage tableAssociationsPage; - - private DefaultTableGenerationWizardPage defaultTableGenerationPage; - - private TablesAndColumnsCustomizationWizardPage tablesAndColumnsCustomizationPage; - - protected final ResourceManager resourceManager; - - public GenerateEntitiesFromSchemaWizard() { - this.resourceManager = new LocalResourceManager(JFaceResources.getResources()); - this.setWindowTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_generateEntities); - } - - public GenerateEntitiesFromSchemaWizard( JpaProject jpaProject, IStructuredSelection selection) { - super(); - this.jpaProject = jpaProject; - this.selection = selection; - this.resourceManager = new LocalResourceManager(JFaceResources.getResources()); - this.setWindowTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_generateEntities); - this.setDefaultPageImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.ENTITY_WIZ_BANNER)); - } - - @Override - public void addPages() { - setForcePreviousAndNextButtons(true); - - //If this.jpaProject is not initialized because user didn't select a JPA project - if( this.jpaProject == null ){ - this.projectPage = new PromptJPAProjectWizardPage(HELP_CONTEXT_ID); - this.addPage(this.projectPage); - return; - } - addMainPages(); - } - - private void addMainPages() { - this.tablesSelectorPage = new TablesSelectorWizardPage(this.jpaProject, this.resourceManager); - this.addPage(this.tablesSelectorPage); - - this.tableAssociationsPage = new TableAssociationsWizardPage(this.jpaProject, this.resourceManager); - this.addPage(this.tableAssociationsPage); - - this.defaultTableGenerationPage = new DefaultTableGenerationWizardPage(this.jpaProject); - this.addPage(this.defaultTableGenerationPage); - this.defaultTableGenerationPage.init(this.selection); - - this.tablesAndColumnsCustomizationPage = new TablesAndColumnsCustomizationWizardPage(this.jpaProject, this.resourceManager); - this.addPage(this.tablesAndColumnsCustomizationPage); - this.tablesAndColumnsCustomizationPage.init(this.selection); - } - - public ORMGenCustomizer getORMGenCustomizer(){ - return this.customizer; - } - - /** - * Create the ORMGenCustomizer when user selects a new connection profile and schema - * - * JpaPlatform implementor can provide a custom ORMGenCustomizer specific to a platform - * with AdapterFactory through Eclipse org.eclipse.core.runtime.adapters extension point: - * <pre> - * - *<extension - * point="org.eclipse.core.runtime.adapters"> - * <factory - * adaptableType="org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkPlatform" - * class="oracle.eclipse.tools.orm.internal.EclipseLinkORMGenCustomizerAdapterFactory"> - * <adapter - * type="oracle.eclipse.tools.orm.internal.ORMGenCustomizer"> - * </adapter> - * </factory> - *</extension> - *</pre> - * - * @param schema - */ - public ORMGenCustomizer createORMGenCustomizer(Schema schema){ - JpaPlatform jpaPlatform = this.jpaProject.getJpaPlatform(); - Object obj = Platform.getAdapterManager().getAdapter( jpaPlatform, ORMGenCustomizer.class ); - if (obj != null && obj instanceof ORMGenCustomizer) { - this.customizer = (ORMGenCustomizer) obj; - this.customizer.init(getCustomizationFile(), schema); - } else{ - this.customizer = new BaseEntityGenCustomizer( ); - this.customizer.init(getCustomizationFile(), schema); - } - - ORMGenTable newDefaultTable = getCustomizer().createGenTable(null); - if ( selection!=null && selection.getFirstElement() instanceof IPackageFragment ) { - IPackageFragment packageFrag = (IPackageFragment)selection.getFirstElement(); - newDefaultTable.setPackage( packageFrag.getElementName() ); - for (IPackageFragmentRoot root : JDTTools.getJavaSourceFolders(this.jpaProject.getJavaProject())) { - String srcFolder = root.getPath().toPortableString(); - if( packageFrag.getPath().toPortableString().startsWith( srcFolder +'/' )){ - newDefaultTable.setSourceFolder(srcFolder.substring(1)); - } - } - } - return this.customizer; - } - - protected String getCustomizationFileName() { - ConnectionProfile profile = getProjectConnectionProfile(); - String connection = profile == null ? "" : profile.getName(); - String name = "org.eclipse.jpt.entitygen." + (connection == null ? "" :connection.replace(' ', '-')); //$NON-NLS-1$ - Schema schema = getDefaultSchema(); - if ( schema!= null ) { - name += "." + schema.getName();//$NON-NLS-1$ - } - return name.toLowerCase(); - } - - /** - * Returns the nodes state file. - */ - private File getCustomizationFile() { - String projectPath = this.jpaProject.getProject().getLocation().toPortableString(); - File genDir = new File(projectPath + "/.settings");//$NON-NLS-1$ - genDir.mkdirs(); - return new File(genDir, getCustomizationFileName()); - } - - @Override - public boolean performFinish() { - if (this.jpaProject == null) { - return true; - } - try { - this.customizer.setDatabaseAnnotationNameBuilder( buildDatabaseAnnotationNameBuilder() ); - this.customizer.save(); - } catch (IOException e) { - JptJpaUiPlugin.log(e); - } - OverwriteConfirmer overwriteConfirmer = null; - if (showOverwriteWarning()) { - overwriteConfirmer = new OverwriteConfirmer(); - } - - WorkspaceJob genEntitiesJob = new GenerateEntitiesJob(this.jpaProject, getCustomizer(), overwriteConfirmer); - genEntitiesJob.schedule(); - return true; - } - - // ********** generate entities job ********** - - static class GenerateEntitiesJob extends WorkspaceJob { - final JpaProject jpaProject; - final ORMGenCustomizer customizer; - final OverwriteConfirmer confirmer; - GenerateEntitiesJob(JpaProject jpaProject, ORMGenCustomizer customizer, OverwriteConfirmer confirmer) { - super(JptUiMessages.EntitiesGenerator_jobName); - this.customizer = customizer; - this.jpaProject = jpaProject; - this.confirmer = confirmer; - IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); - this.setRule(ruleFactory.modifyRule(jpaProject.getProject())); - } - - @Override - public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { - PackageGenerator.generate(this.jpaProject,this.customizer, this.confirmer, monitor); - return Status.OK_STATUS; - } - } - - public static boolean showOverwriteWarning(){ - IEclipsePreferences pref = new InstanceScope().getNode(JptJpaUiPlugin.PLUGIN_ID); - boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ; - return ret; - } - - // ********** overwrite confirmer ********** - - static class OverwriteConfirmer implements org.eclipse.jpt.jpa.gen.internal.OverwriteConfirmer { - private boolean overwriteAll = false; - private boolean skipAll = false; - - OverwriteConfirmer() { - } - - public boolean overwrite(final String className) { - if (this.overwriteAll) { - return true; - } - if (this.skipAll) { - return false; - } - return this.promptUser(className); - } - - private boolean promptUser(final String className) { - // get on the UI thread synchronously, need feedback before continuing - final boolean ret[]=new boolean[1]; - Display.getDefault().syncExec(new Runnable() { - public void run() { - final OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(Display.getCurrent().getActiveShell(), className); - dialog.open(); - if (dialog.getReturnCode() == Window.CANCEL) { - //throw new OperationCanceledException(); - skipAll = true; - ret[0] = false; - return; - } - if (dialog.yes()) { - ret[0] = true; - } - if (dialog.yesToAll()) { - overwriteAll = true; - ret[0] = true; - } - if (dialog.no()) { - ret[0] = false; - } - if (dialog.noToAll()) { - skipAll = true; - ret[0] = false; - } - } - }); - return ret[0]; - } - - } - - - // ********** overwrite dialog ********** - - static class OverwriteConfirmerDialog extends Dialog { - private final String className; - private boolean yes = false; - private boolean yesToAll = false; - private boolean no = false; - private boolean noToAll = false; - - OverwriteConfirmerDialog(Shell parent, String className) { - super(parent); - this.className = className; - } - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(JptUiMessages.OverwriteConfirmerDialog_title); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - GridLayout gridLayout = (GridLayout) composite.getLayout(); - gridLayout.numColumns = 1; - - Label text = new Label(composite, SWT.LEFT); - text.setText(NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, this.className)); - text.setLayoutData(new GridData()); - - createDontShowControl(composite); - - return composite; - } - - protected Control createDontShowControl(Composite composite) { - final Button checkbox = new Button( composite, SWT.CHECK ); - checkbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_doNotShowWarning ); - checkbox.setSelection(false); - final IEclipsePreferences pref = new InstanceScope().getNode( JptJpaUiPlugin.PLUGIN_ID); - checkbox.setLayoutData( new GridData(GridData.FILL_BOTH) ); - checkbox.addSelectionListener(new SelectionListener (){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - boolean b = checkbox.getSelection(); - pref.putBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, b); - } - }); - return checkbox; - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); - this.createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false); - this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); - this.createButton(parent, IDialogConstants.NO_TO_ALL_ID, IDialogConstants.NO_TO_ALL_LABEL, false); - this.createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - @Override - protected void buttonPressed(int buttonId) { - switch (buttonId) { - case IDialogConstants.YES_ID : - this.yesPressed(); - break; - case IDialogConstants.YES_TO_ALL_ID : - this.yesToAllPressed(); - break; - case IDialogConstants.NO_ID : - this.noPressed(); - break; - case IDialogConstants.NO_TO_ALL_ID : - this.noToAllPressed(); - break; - case IDialogConstants.CANCEL_ID : - this.cancelPressed(); - break; - default : - break; - } - } - - private void yesPressed() { - this.yes = true; - this.setReturnCode(OK); - this.close(); - } - - private void yesToAllPressed() { - this.yesToAll = true; - this.setReturnCode(OK); - this.close(); - } - - private void noPressed() { - this.no = true; - this.setReturnCode(OK); - this.close(); - } - - private void noToAllPressed() { - this.noToAll = true; - this.setReturnCode(OK); - this.close(); - } - - boolean yes() { - return this.yes; - } - - boolean yesToAll() { - return this.yesToAll; - } - - boolean no() { - return this.no; - } - - boolean noToAll() { - return this.noToAll; - } - } - - - private DatabaseAnnotationNameBuilder buildDatabaseAnnotationNameBuilder() { - return new LocalDatabaseAnnotationNameBuilder(this.jpaProject.getJpaPlatform().getEntityGeneratorDatabaseAnnotationNameBuilder()); - } - - // ********** name builder adapter ********** - - /** - * adapt the JPA platform-supplied builder to the builder interface - * expected by the entity generator - */ - static class LocalDatabaseAnnotationNameBuilder implements DatabaseAnnotationNameBuilder { - private EntityGeneratorDatabaseAnnotationNameBuilder builder; - LocalDatabaseAnnotationNameBuilder(EntityGeneratorDatabaseAnnotationNameBuilder builder) { - super(); - this.builder = builder; - } - public String buildTableAnnotationName(String entityName, Table table) { - return this.builder.buildTableAnnotationName(entityName, table); - } - public String buildColumnAnnotationName(String attributeName, Column column) { - return this.builder.buildColumnAnnotationName(attributeName, column); - } - public String buildJoinColumnAnnotationName(String attributeName, ForeignKey foreignKey) { - return this.builder.buildJoinColumnAnnotationName(attributeName, foreignKey); - } - public String buildJoinColumnAnnotationName(Column column) { - return this.builder.buildJoinColumnAnnotationName(column); - } - public String buildJoinTableAnnotationName(Table table) { - return this.builder.buildJoinTableAnnotationName(table); - } - } - - @Override - public IWizardPage getStartingPage() { - if (this.projectPage != null) { - if (this.tablesSelectorPage != null) { - return this.tablesSelectorPage; - } - return this.projectPage; - } - return super.getStartingPage(); - } - - public ORMGenCustomizer getCustomizer (){ - return customizer; - } -// Collection<Table> getPossibleTables() { -// if ( this.tablesSelectorPage != null) { -// return this.tablesSelectorPage.getTables(); -// } -// return ( this.projectDefaultSchemaExists()) ? CollectionTools.collection( this.getDefaultSchema().tables()) : Collections.<Table>emptyList(); -// } - - public ConnectionProfile getProjectConnectionProfile() { - return this.jpaProject.getConnectionProfile(); - } - - public JpaProject getJpaProject(){ - return this.jpaProject; - } - - public void setJpaProject(JpaProject jpaProject) { - if (this.jpaProject == null) { - this.jpaProject = jpaProject; - IWizardPage currentPage = getContainer().getCurrentPage(); - if (this.projectPage != null && currentPage.equals(this.projectPage)) { - addMainPages(); - } - } - } - - public Schema getDefaultSchema() { - return getJpaProject().getDefaultDbSchema(); - } - - public void init(IWorkbench workbench, IStructuredSelection selection) { - Object sel = selection.getFirstElement(); - if ( sel instanceof IResource ) { - IProject proj = ((IResource) sel).getProject(); - JpaProject jpaProj = JptJpaCorePlugin.getJpaProject(proj); - this.jpaProject = jpaProj; - } else if( sel instanceof org.eclipse.jdt.core.IPackageFragmentRoot ) { - org.eclipse.jdt.core.IPackageFragmentRoot root = (org.eclipse.jdt.core.IPackageFragmentRoot) sel; - IProject proj = root.getJavaProject().getProject(); - JpaProject jpaProj = JptJpaCorePlugin.getJpaProject(proj); - this.jpaProject = jpaProj; - } else if( sel instanceof org.eclipse.jdt.core.IPackageFragment) { - org.eclipse.jdt.core.IPackageFragment frag = (org.eclipse.jdt.core.IPackageFragment) sel; - IProject proj = frag.getJavaProject().getProject(); - JpaProject jpaProj = JptJpaCorePlugin.getJpaProject(proj); - this.jpaProject = jpaProj; - } - - this.selection = selection; - this.setWindowTitle(JptUiEntityGenMessages.GenerateEntitiesWizard_generateEntities); - } - - @Override - public void dispose() { - this.resourceManager.dispose(); - super.dispose(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/JoinColumnsPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/JoinColumnsPage.java deleted file mode 100644 index 4bde36bf71..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/JoinColumnsPage.java +++ /dev/null @@ -1,629 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.TreeMap; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.dialogs.IPageChangedListener; -import org.eclipse.jface.dialogs.PageChangedEvent; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.util.TableLayoutComposite; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; - - -public class JoinColumnsPage extends NewAssociationWizardPage { - - private Label joinColumnsDescLabel1; - /*the table containing the association columns between table1 and table2 - * , or table1 and join table if many to many*/ - private TableViewer joinColumnsTable1; - private ArrayList<SimpleJoin> tableDataModel1 = new ArrayList<SimpleJoin>(); - private Composite tablesGroup1; - - private Label joinColumnsDescLabel2; - /*the table containing the association columns between join table and table2 - * if many to many*/ - private TableViewer joinColumnsTable2; - private ArrayList<SimpleJoin> tableDataModel2 = new ArrayList<SimpleJoin>(); - private Composite tablesGroup2; - - static final String[] JOINCOLUMNS_TABLE_COLUMN_PROPERTIES = { "referrerColumn", "referencedColumn" }; - - private static final int JOINCOLUMN1_COLUMN_INDEX = 0; - private static final int JOINCOLUMN2_COLUMN_INDEX = 1; - - protected JoinColumnsPage(ORMGenCustomizer customizer ) { - super(customizer, "JoinColumnsPage"); - setTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_title); - setDescription(JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_desc); - } - - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - composite.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_JOIN_COLUMNS); - - tablesGroup1 = new Composite(composite, SWT.SHADOW_ETCHED_IN); - tablesGroup1.setLayoutData(new GridData()); - tablesGroup1.setLayout(new GridLayout(2, false)); - createJoinColumnsTableControl1(tablesGroup1); - - //createMtmJoinColumnsTable2(composite); - - setControl(composite); - this.setPageComplete( false); - - ((WizardDialog)getContainer()).addPageChangedListener(new IPageChangedListener(){ - public void pageChanged(PageChangedEvent event) { - if( event.getSelectedPage() == JoinColumnsPage.this ){ - ((Composite)JoinColumnsPage.this.getControl()).getParent().layout() ; - - } - } - }); - } - - private void createMtmJoinColumnsTable2(Composite composite) { - tablesGroup2 = new Composite(composite, SWT.SHADOW_ETCHED_IN); - tablesGroup2.setLayoutData(new GridData()); - tablesGroup2.setLayout(new GridLayout(2, false)); - createJoinColumnsTableControl2(tablesGroup2); - } - - /** - * Update wizard page UI with new table names - */ - @Override - public void updateWithNewTables() { - String cardinality = this.getCardinality() ; - if( Association.MANY_TO_MANY.equals( cardinality ) ){ - updateWithMtmTables(); - }else{ - updateWithOtmTables(); - } - } - - /** - * Update Wizard UI with a single TableViewer with columns from the two associated database tables - */ - public void updateWithOtmTables() { - TableColumn[] columns = joinColumnsTable1.getTable().getColumns(); - String table1Name = this.getReferrerTableName() ; - String table2Name = this.getReferencedTableName() ; - - if( table1Name ==null || table2Name == null ) - return; - - columns[0].setText( table1Name ); - columns[1].setText( table2Name ); - - //Hide the Join column table 2 - if( tablesGroup2 !=null ) - tablesGroup2.setVisible(false); - - tableDataModel1.clear(); - joinColumnsTable1.refresh(); - - String msg = String.format(JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_label, table1Name, table2Name); - joinColumnsDescLabel1.setText(msg); - joinColumnsDescLabel1.setToolTipText( msg ); - tablesGroup1.layout(); - - String[] referrerColumnValues = getTableColumns(table1Name); - String[] referencedColumnValues = getTableColumns(table2Name); - - updateCellEditors(joinColumnsTable1, referrerColumnValues, referencedColumnValues); - - - ((Composite)this.getControl()).layout() ; - } - - /** - * Update Wizard UI with a two TableViewers with the first with columns from table1 to the MTM join table - * and the second one with columns from the MTM join table to table2 - */ - public void updateWithMtmTables() { - TableColumn[] columns = joinColumnsTable1.getTable().getColumns(); - String table1Name = this.getReferrerTableName() ; - String table2Name = this.getReferencedTableName() ; - String joinTableName = this.getJoinTableName() ; - if( table1Name==null || table2Name==null || joinTableName==null ){ - return; - } - if( tablesGroup2 == null ){ - createMtmJoinColumnsTable2( tablesGroup1.getParent()); - } - - columns[0].setText( table1Name==null?"":table1Name ); - columns[1].setText( table2Name==null?"":joinTableName ); - - //Update join column TableViewer 1 - tableDataModel1.clear(); - joinColumnsTable1.refresh(); - - String msg = String.format(JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_label, table1Name, joinTableName); - joinColumnsDescLabel1.setText(msg); - joinColumnsDescLabel1.setToolTipText( msg ); - String[] referrerColumnValues = getTableColumns(table1Name); - String[] referencedColumnValues = getTableColumns(joinTableName); - - updateCellEditors(joinColumnsTable1, referrerColumnValues, referencedColumnValues ); - - //Update join column TableViewer 2 - columns = joinColumnsTable2.getTable().getColumns(); - columns[0].setText( joinTableName==null?"":joinTableName ); - columns[1].setText( table2Name==null?"":table2Name ); - tablesGroup1.layout(); - - tableDataModel2.clear(); - joinColumnsTable2.refresh(); - msg = String.format(JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_label, joinTableName, table2Name); - joinColumnsDescLabel2.setText(msg); - joinColumnsDescLabel2.setToolTipText( msg ); - referrerColumnValues = getTableColumns(joinTableName); - referencedColumnValues = getTableColumns(table2Name); - updateCellEditors(joinColumnsTable2, referrerColumnValues, referencedColumnValues ); - - tablesGroup2.layout(); - - //Show the Join column TableViewer 2 - tablesGroup2.setVisible(true); - - - ((Composite)this.getControl()).layout(new Control[]{this.tablesGroup1, this.tablesGroup2}); - } - - - private void createAddRemoveButtonComposite(Composite tablesGroup, final TableViewer joinColumnsTable, final ArrayList<SimpleJoin> tableDataModel) { - //Add and Remove JoinColumns buttons - Composite buttonComposite = new Composite(tablesGroup, SWT.NULL); - GridLayout buttonLayout = new GridLayout(1, false); - buttonComposite.setLayout(buttonLayout); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.BEGINNING; - buttonComposite.setLayoutData(data); - - Button addButton = new Button(buttonComposite, SWT.PUSH); - addButton.setText( JptUiEntityGenMessages.add ); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - addButton.setLayoutData(gridData); - addButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - @SuppressWarnings("unchecked") - public void widgetSelected(SelectionEvent e) { - - SimpleJoin join = getDefaultNewJoin(joinColumnsTable); - tableDataModel.add(join); - joinColumnsTable.refresh(); - - //Update Wizard model - TreeMap<String, String> joins = null; - if( joinColumnsTable == joinColumnsTable1 ){ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1 ); - }else{ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2 ); - } - joins.put( join.foreignKey, join.primaryKey); - - updatePageComplete(); - } - }); - - Button removeButton = new Button(buttonComposite, SWT.PUSH); - removeButton.setText( JptUiEntityGenMessages.remove ); - gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - removeButton.setLayoutData(gridData); - removeButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - @SuppressWarnings("unchecked") - public void widgetSelected(SelectionEvent e) { - StructuredSelection selection = (StructuredSelection)joinColumnsTable.getSelection(); - if( selection.isEmpty()) - return; - SimpleJoin join = (SimpleJoin)selection.getFirstElement(); - - //Update TableViewer model - tableDataModel.remove( join ); - //Update Wizard model - - TreeMap<String, String> joins = null; - if( joinColumnsTable == joinColumnsTable1 ){ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1 ); - }else{ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2 ); - } - joins.remove(join.foreignKey); - - joinColumnsTable.refresh(); - } - }); - - addButton.setFocus(); - - } - - protected SimpleJoin getDefaultNewJoin(TableViewer joinColumnsTable) { - String table1Name = ""; - String table2Name = ""; - - TreeMap<String, String> existingJoins = null; - if( joinColumnsTable == this.joinColumnsTable1 ){ - existingJoins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1 ); - if( this.getJoinTableName() == null) { - table1Name = this.getReferrerTableName(); - table2Name = this.getReferencedTableName() ; - }else{ - table1Name = this.getReferrerTableName(); - table2Name = this.getJoinTableName() ; - } - }else{ - existingJoins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2 ); - table1Name = this.getJoinTableName(); - table2Name = this.getReferencedTableName() ; - } - //find next available column - String[] table1ColumnValues = getTableColumns(table1Name); - String nextCol1 = ""; - for( String s: table1ColumnValues ){ - if( !existingJoins.keySet().contains(s)){ - nextCol1 = s; - break; - } - } - - String[] table2ColumnValues = getTableColumns(table2Name); - String nextCol2 = ""; - for( String s: table2ColumnValues ){ - if( !existingJoins.values().contains(s)){ - nextCol2 = s; - break; - } - } - return new SimpleJoin( nextCol1, nextCol2); - } - - @Override - public boolean canFlipToNextPage() { - return isPageComplete(); - } - - public void updatePageComplete() { - boolean ret = tableDataModel1.size()> 0 ; - setPageComplete( ret ); - } - - private Label createLabel(Composite container, int span, String text) { - Label label = new Label(container, SWT.NONE); - label.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - label.setLayoutData(gd); - return label; - } - - private void createJoinColumnsTableControl1(Composite tablesGroup) { - joinColumnsDescLabel1 = createLabel(tablesGroup, 2, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_label ); - joinColumnsTable1 = createJoinColumnsTableControl(tablesGroup, this.tableDataModel1); - createAddRemoveButtonComposite(tablesGroup, joinColumnsTable1, tableDataModel1); - } - - private void createJoinColumnsTableControl2(Composite tablesGroup) { - joinColumnsDescLabel2 = createLabel(tablesGroup, 2, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_colsPage_label ); - joinColumnsTable2 = createJoinColumnsTableControl(tablesGroup, this.tableDataModel2); - createAddRemoveButtonComposite(tablesGroup, joinColumnsTable2, tableDataModel2); - } - - private TableViewer createJoinColumnsTableControl(Composite parent, ArrayList<SimpleJoin> tableDataModel ){ - - TableLayoutComposite layout= new TableLayoutComposite(parent, SWT.NONE); - addColumnLayoutData(layout); - - final org.eclipse.swt.widgets.Table table = new org.eclipse.swt.widgets.Table(layout, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER ); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableColumn referrerColumn = new TableColumn(table, SWT.NONE, JOINCOLUMN1_COLUMN_INDEX); - referrerColumn.setText("%table1"); - referrerColumn.setResizable(true); - - TableColumn referencedColumn = new TableColumn(table, SWT.NONE, JOINCOLUMN2_COLUMN_INDEX); - referencedColumn.setText("%table2"); - referencedColumn.setResizable(true); - - GridData gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= SWTUtil.getTableHeightHint(table, 3); - gd.widthHint = 300; - layout.setLayoutData(gd); - - TableViewer newJoinColumnsTable = new TableViewer(table); - newJoinColumnsTable.setUseHashlookup(true); - newJoinColumnsTable.setLabelProvider(this.buildTableTableLabelProvider()); - newJoinColumnsTable.setContentProvider(this.buildTableTableContentProvider()); - newJoinColumnsTable.setSorter(new ViewerSorter() { - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - return ((SimpleJoin) e1).foreignKey.compareTo(((SimpleJoin) e2).foreignKey); - } - }); - - newJoinColumnsTable.addPostSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - //handleTablesListSelectionChanged(event); - } - }); - populateTableDataModel(); - newJoinColumnsTable.setInput( tableDataModel ); - return newJoinColumnsTable; - } - - @SuppressWarnings("unchecked") - public void populateTableDataModel(){ - HashMap<String, Object> dataModel = getWizardDataModel(); - TreeMap<String, String> joinColumns = (TreeMap<String, String>)dataModel.get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1); - if( joinColumns!= null ){ - for( String referrerColumn : joinColumns.keySet() ){ - tableDataModel1.add(new SimpleJoin(referrerColumn, joinColumns.get(referrerColumn) )); - } - } - - TreeMap<String, String> joinColumns2 = (TreeMap<String, String>)dataModel.get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2); - if( joinColumns2!= null ){ - for( String referrerColumn : joinColumns2.keySet() ){ - tableDataModel2.add(new SimpleJoin(referrerColumn, joinColumns2.get(referrerColumn) )); - } - } - - } - - private IContentProvider buildTableTableContentProvider() { - return new JoinColumnsContentProvider(); - } - - - private IBaseLabelProvider buildTableTableLabelProvider() { - return new JoinColumnsTableLabelProvider(); - } - - - private void addColumnLayoutData(TableLayoutComposite layout) { - layout.addColumnData(new ColumnWeightData(50, true)); - layout.addColumnData(new ColumnWeightData(50, true)); - } - - - private void updateCellEditors(TableViewer joinColumnsTable, String[] referrerColumnValues, String[] referencedColumnValues ){ - joinColumnsTable.setColumnProperties(JOINCOLUMNS_TABLE_COLUMN_PROPERTIES); - ComboBoxCellEditor[] editors = new ComboBoxCellEditor[JOINCOLUMNS_TABLE_COLUMN_PROPERTIES.length]; - - editors[JOINCOLUMN1_COLUMN_INDEX]= new ComboBoxCellEditor(joinColumnsTable.getTable(), referrerColumnValues, SWT.SINGLE); - editors[JOINCOLUMN2_COLUMN_INDEX]= new ComboBoxCellEditor(joinColumnsTable.getTable(), referencedColumnValues, SWT.SINGLE); - - joinColumnsTable.setCellEditors(editors); - joinColumnsTable.setCellModifier(this.buildTableTableCellModifier(joinColumnsTable, referrerColumnValues, referencedColumnValues )); - } - - public String[] getTableColumns(String tableName){ - Schema schema = (Schema)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_SCHEMA); - Table table = schema.getTableNamed(tableName); - List<String> list = new ArrayList<String>(); - for (Column column : table.getColumns()) { - list.add(column.getName()); - } - String[] ret = new String[list.size()]; - list.toArray(ret); - return ret; - } - - private ICellModifier buildTableTableCellModifier(TableViewer joinColumnsTable, String[] referrerColumnValues, String[] referencedColumnValues) { - return new JoinColumnsCellModifier(joinColumnsTable, referrerColumnValues, referencedColumnValues); - } - - /** - * A ContentProvider translates the SimpleJoin list into a Collection for display - * - */ - private class JoinColumnsContentProvider implements IStructuredContentProvider { - - JoinColumnsContentProvider() { - super(); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} - public void dispose() {} - public Object[] getElements(Object inputElement) { - return ((Collection<?>) inputElement).toArray(); - } - } - - /** - * Simple value object used as model backing the JFace table - * - */ - private class SimpleJoin { - public SimpleJoin(String foreignKey, String primaryKey) { - this.foreignKey = foreignKey; - this.primaryKey = primaryKey; - } - public String foreignKey; - public String primaryKey; - - @Override - public String toString(){ - return "["+ this.foreignKey + " = " + this.primaryKey + "]"; - } - } - - /** - * A CellModifier to update the join columns in the wizard data model - */ - private class JoinColumnsCellModifier implements ICellModifier { - private TableViewer joinColumnsTable; - private String[] referrerColumnValues; - private String[] referencedColumnValues; - JoinColumnsCellModifier(TableViewer joinColumnsTable, String[] referrerColumnValues, String[] referencedColumnValues) { - super(); - this.joinColumnsTable = joinColumnsTable; - this.referrerColumnValues = referrerColumnValues; - this.referencedColumnValues = referencedColumnValues; - } - - public boolean canModify(Object element, String property) { - return true; - } - - @SuppressWarnings("unchecked") - public Object getValue(Object element, String property) { -// SimpleJoin join = (SimpleJoin) element; -// if (property.equals(JOINCOLUMNS_TABLE_COLUMN_PROPERTIES[JOINCOLUMN2_COLUMN_INDEX])) { -// return join.primaryKey; -// } -// return join.foreignKey; - // returnt the index of the value in the ComboxCellEditor - ArrayList<SimpleJoin> tableDataModel = (ArrayList<SimpleJoin>) joinColumnsTable.getInput(); - for(int i=0; i< tableDataModel.size(); i ++ ){ - if( tableDataModel.get(i) == element ) - return new Integer(i); - } - return new Integer(0); - - } - - /** - * element is the selected TableItem - * value is the selected item index in the comboCellEditor - */ - @SuppressWarnings("unchecked") - public void modify(Object element, String property, Object value) { - if ( ! (element instanceof TableItem)) { - return; - } - Integer index = (Integer)value; - TableItem item = (TableItem)element; - boolean unchanged = false; - SimpleJoin join = (SimpleJoin) item.getData(); - if (property.equals(JOINCOLUMNS_TABLE_COLUMN_PROPERTIES[JOINCOLUMN1_COLUMN_INDEX])) { - unchanged = join.foreignKey.equals( referrerColumnValues[ index.intValue() ] ); - if (! unchanged) { - - //update the wizard datamodel - TreeMap<String, String> joins = null; - if( joinColumnsTable == joinColumnsTable1 ){ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1 ); - }else{ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2 ); - } - joins.remove(join.foreignKey); - joins.put(referrerColumnValues[ index.intValue() ], join.primaryKey); - - //Update the TableViewer model - join.foreignKey = referrerColumnValues[ index.intValue()]; - joinColumnsTable.refresh(); - } - return; - } - - if (property.equals(JOINCOLUMNS_TABLE_COLUMN_PROPERTIES[JOINCOLUMN2_COLUMN_INDEX])) { - unchanged = join.primaryKey.equals( referencedColumnValues[ index.intValue()] ) ; - if (! unchanged) { - //Update the TableViewer model - join.primaryKey = referencedColumnValues[ index.intValue()] ; - - //Update wizard data model - TreeMap<String, String> joins = null; - if( joinColumnsTable == joinColumnsTable1 ){ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1 ); - }else{ - joins = (TreeMap<String, String>)getWizardDataModel().get(NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2 ); - } - joins.put(join.foreignKey, join.primaryKey); - - joinColumnsTable.refresh(); - } - } - - - } - - } - - /** - * A table label provider to return the join column names for display - * - */ - private final class JoinColumnsTableLabelProvider extends LabelProvider implements ITableLabelProvider { - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - public String getColumnText(Object element, int columnIndex) { - if( !(element instanceof SimpleJoin) ) - return null; - switch (columnIndex) { - case 0: - return ((SimpleJoin)element).foreignKey; - case 1: - return ((SimpleJoin)element).primaryKey; - default: - Assert.isTrue(false); - return null; - } - } - @Override - public String getText(Object element) { - return getColumnText(element, 0); // needed to make the sorter work - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/JptUiEntityGenMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/JptUiEntityGenMessages.java deleted file mode 100644 index dafe41f126..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/JptUiEntityGenMessages.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali UI. - * - * @version 2.0 - * @since 2.0 - */ -public class JptUiEntityGenMessages { - private static final String BUNDLE_NAME = "jpt_ui_entity_gen"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptUiEntityGenMessages.class; - - public static String GenerateEntitiesWizard_tableSelectPage_Restore_Defaults; - public static String GenerateEntitiesWizard_generateEntities; - public static String GenerateEntitiesWizard_doNotShowWarning; - public static String GenerateEntitiesWizard_selectJPAProject; - public static String GenerateEntitiesWizard_selectJPAProject_msg; - public static String GenerateEntitiesWizard_tableSelectPage_selectTable; - public static String GenerateEntitiesWizard_tableSelectPage_chooseEntityTable; - public static String GenerateEntitiesWizard_tableSelectPage_updatePersistenceXml; - public static String GenerateEntitiesWizard_tableSelectPage_tables; - public static String GenerateEntitiesWizard_tableSelectPage_tableColumn; - //Database connection group - public static String connection; - public static String addConnectionLink; - public static String connectLink; - public static String schemaInfo; - public static String schema; - public static String connectingToDatabase; - - //Default table gen properties - public static String GenerateEntitiesWizard_defaultTablePage_title; - public static String GenerateEntitiesWizard_defaultTablePage_desc; - public static String GenerateEntitiesWizard_defaultTablePage_domainJavaClass; - public static String GenerateEntitiesWizard_defaultTablePage_tableMapping; - public static String GenerateEntitiesWizard_tablePanel_className; - public static String GenerateEntitiesWizard_defaultTablePage_fetch; - public static String GenerateEntitiesWizard_defaultTablePage_collType; - public static String GenerateEntitiesWizard_defaultTablePage_sequence; - public static String GenerateEntitiesWizard_defaultTablePage_sequenceNote; - public static String GenerateEntitiesWizard_defaultTablePage_access; - public static String GenerateEntitiesWizard_defaultTablePage_keyGen; - public static String GenerateEntitiesWizard_defaultTablePage_genOptionalAnnotations; - public static String GenerateEntitiesWizard_defaultTablePage_genOptionalAnnotations_desc; - - //Asso figure - public static String manyToOneDesc; - public static String oneToOneDesc; - public static String manyToManyDesc; - //table association wizard page - public static String GenerateEntitiesWizard_assocPage_title; - public static String GenerateEntitiesWizard_assocPage_desc; - public static String GenerateEntitiesWizard_assocPage_label; - public static String GenerateEntitiesWizard_assocPage_newAssoc; - public static String GenerateEntitiesWizard_assocPage_delAssoc; - public static String GenerateEntitiesWizard_assocEditor_genAssoc; - public static String GenerateEntitiesWizard_assocEditor_entityRef; - public static String property; - public static String cascade; - public static String GenerateEntitiesWizard_assocEditor_setRef; - public static String GenerateEntitiesWizard_assocEditor_joinedWhen; - public static String GenerateEntitiesWizard_assocEditor_tableJoin; - public static String cardinality; - public static String selectCascadeDlgTitle; - //new association wizard - public static String GenerateEntitiesWizard_newAssoc_title; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_title; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_desc; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_assocKind; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_simpleAssoc; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_m2mAssoc; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_assocTables; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_table1; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_table2; - public static String GenerateEntitiesWizard_newAssoc_tablesPage_intermediateTable; - public static String GenerateEntitiesWizard_newAssoc_colsPage_title; - public static String GenerateEntitiesWizard_newAssoc_colsPage_desc; - public static String GenerateEntitiesWizard_newAssoc_colsPage_label; - public static String add; - public static String remove; - public static String GenerateEntitiesWizard_newAssoc_cardinalityPage_title; - public static String GenerateEntitiesWizard_newAssoc_cardinalityPage_desc; - public static String manyToOne; - public static String oneToMany; - public static String oneToOne; - public static String manyToMany; - //select table dialog - public static String selectTableDlgTitle; - public static String selectTableDlgDesc; - //individual table and column gen properties - public static String GenerateEntitiesWizard_tablesAndColumnsPage_title; - public static String GenerateEntitiesWizard_tablesAndColumnsPage_desc; - public static String GenerateEntitiesWizard_tablesAndColumnsPage_labelTableAndColumns; - public static String GenerateEntitiesWizard_colPanel_genProp; - public static String GenerateEntitiesWizard_colPanel_colMapping; - public static String GenerateEntitiesWizard_colPanel_propName; - public static String GenerateEntitiesWizard_colPanel_propType; - public static String GenerateEntitiesWizard_colPanel_mapKind; - public static String GenerateEntitiesWizard_colPanel_colUpdateable; - public static String GenerateEntitiesWizard_colPanel_colInsertable; - public static String GenerateEntitiesWizard_colPanel_beanProp; - public static String GenerateEntitiesWizard_colPanel_getterScope; - public static String GenerateEntitiesWizard_colPanel_setterScope; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptUiEntityGenMessages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/NewAssociationWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/NewAssociationWizard.java deleted file mode 100644 index 667b9d05af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/NewAssociationWizard.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.TreeMap; - -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; - - -public class NewAssociationWizard extends Wizard { - - public static String ASSOCIATION_SCHEMA = "ASSOCIATION_SCHEMA"; //$NON-NLS-1$ - public static String ASSOCIATION_REFERRER_TABLE = "ASSOCIATION_REFERRER_TABLE"; //$NON-NLS-1$ - public static String ASSOCIATION_REFERENCED_TABLE = "ASSOCIATION_REFERENCED_TABLE"; //$NON-NLS-1$ - public static String ASSOCIATION_JOIN_COLUMNS1 = "ASSOCIATION_REFERRER_COLUMNS1"; //$NON-NLS-1$ - public static String ASSOCIATION_JOIN_COLUMNS2 = "ASSOCIATION_REFERRER_COLUMNS2"; //used in MTM associations only //$NON-NLS-1$ - public static String ASSOCIATION_JOIN_TABLE = "ASSOCIATION_JOIN_TABLE"; // TreeMap<String, String> //$NON-NLS-1$ - public static String ASSOCIATION_CADINALITY = "ASSOCIATION_CADINALITY"; //$NON-NLS-1$ - - private JpaProject jpaProject; - private HashMap<String, Object> associationDataModel = new HashMap<String, Object>(); - - private ORMGenCustomizer customizer = null; - - private AssociationTablesPage associationTablesPage; - private JoinColumnsPage joinColumnsPage; - private CardinalityPage cardinalityPage; - - protected final ResourceManager resourceManager; - - public NewAssociationWizard( JpaProject jpaProject, ORMGenCustomizer customizer, ResourceManager resourceManager) { - super(); - this.jpaProject = jpaProject; - this.customizer = customizer; - this.resourceManager = resourceManager; - this.setWindowTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_title); - - this.associationDataModel.put( NewAssociationWizard.ASSOCIATION_SCHEMA, this.customizer.getSchema()); - this.associationDataModel.put( NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1, new TreeMap<String, String>()); - this.associationDataModel.put( NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2, new TreeMap<String, String>()); - } - - @Override - public void addPages() { - super.addPages(); - this.associationTablesPage = new AssociationTablesPage( customizer, this.resourceManager); - addPage(this.associationTablesPage); - - this.joinColumnsPage = new JoinColumnsPage(customizer); - addPage(this.joinColumnsPage); - - this.cardinalityPage = new CardinalityPage(customizer); - addPage(this.cardinalityPage); - } - - @Override - public boolean performFinish() { - return true; - } - - public ORMGenCustomizer getCustomizer (){ - return customizer; - } - - public JpaProject getJpaProject(){ - return this.jpaProject; - } - -// public Schema getDefaultSchema() { -// return getJpaProject().getDefaultDbSchema(); -// } -// -// private boolean projectDefaultSchemaExists() { -// return ( this.getDefaultSchema() != null); -// } - - public HashMap<String, Object> getDataModel(){ - return this.associationDataModel; - } - - public void updateTableNames(){ - IWizardPage[] pages = this.getPages(); - for( IWizardPage page : pages){ - ((NewAssociationWizardPage)page).updateWithNewTables(); - } - } - - @SuppressWarnings("unchecked") - public Association getNewAssociation(){ - String referrerTableName =getReferrerTableName(); - String referencedTableName = getReferencedTableName(); - List<String> referrerColNames = new ArrayList<String>(); - List<String> referencedColNames = new ArrayList<String>(); - - String cardinality = (String)associationDataModel.get( NewAssociationWizard.ASSOCIATION_CADINALITY ); - if( cardinality.equals(Association.MANY_TO_MANY) ){ - return createManyToManyAssociation(); - } - - Object value = associationDataModel.get( NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1); - if(value!=null){ - TreeMap<String, String> joinColumns = (TreeMap<String, String>)value; - for( String pk : joinColumns.keySet()){ - referrerColNames.add(pk); - referencedColNames.add( joinColumns.get(pk)); - } - } - - /*if one-to-many then convert it to many-to-one to be consistent - * with the associations computed from the db foreign keys. - * Don't see at this point how one-to-many would - * affect the generation.*/ - if( cardinality.equals(Association.ONE_TO_MANY) ){ - cardinality = Association.MANY_TO_ONE; - - String temp1 = referrerTableName; - referrerTableName = referencedTableName; - referencedTableName = temp1; - - List<String> temp2 = referrerColNames; - referrerColNames = referencedColNames; - referencedColNames = temp2; - } - - Association association = null; - association = new Association(this.customizer, referrerTableName, referrerColNames , referencedTableName, referencedColNames); - association.setCardinality( cardinality ); - association.setCustom(true); - return association; - } - - @SuppressWarnings("unchecked") - private Association createManyToManyAssociation() { - String referrerTableName =getReferrerTableName(); - String joinTable = getJoinTableName(); - String referencedTableName = getReferencedTableName(); - - List<String> referrerColNames = new ArrayList<String>(); - List<String> referrerJoinColNames = new ArrayList<String>(); - Object value = associationDataModel.get( NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS1); - if(value!=null){ - TreeMap<String, String> joinColumns = (TreeMap<String, String>)value; - for( String pk : joinColumns.keySet()){ - referrerColNames.add(pk); - referrerJoinColNames.add( joinColumns.get(pk)); - } - } - - value = associationDataModel.get( NewAssociationWizard.ASSOCIATION_JOIN_COLUMNS2); - List<String> referencedColNames = new ArrayList<String>(); - List<String> referencedJoinColNames = new ArrayList<String>(); - if(value!=null){ - TreeMap<String, String> joinColumns = (TreeMap<String, String>)value; - for( String pk : joinColumns.keySet()){ - referencedJoinColNames.add(pk); - referencedColNames.add( joinColumns.get(pk)); - } - } - - - Association association = null; - association = new Association(this.customizer, referrerTableName, referrerColNames, - referencedTableName, referencedColNames, joinTable, referrerJoinColNames, referencedJoinColNames); - return association; - } - - String getReferrerTableName(){ - return (String)associationDataModel.get(NewAssociationWizard.ASSOCIATION_REFERRER_TABLE); - } - - String getReferencedTableName(){ - return (String)associationDataModel.get(NewAssociationWizard.ASSOCIATION_REFERENCED_TABLE); - } - - String getJoinTableName(){ - return (String)associationDataModel.get(NewAssociationWizard.ASSOCIATION_JOIN_TABLE ); - } - - String getCardinality(){ - return (String)associationDataModel.get(NewAssociationWizard.ASSOCIATION_CADINALITY ); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/NewAssociationWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/NewAssociationWizardPage.java deleted file mode 100644 index 8263181770..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/NewAssociationWizardPage.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.wizards.gen; - -import java.util.HashMap; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - - -public abstract class NewAssociationWizardPage extends WizardPage { - - protected ORMGenCustomizer customizer; - - public NewAssociationWizardPage(ORMGenCustomizer customizer, String name) { - super(name); - this.customizer = customizer ; - } - - protected HashMap<String, Object> getWizardDataModel(){ - return ((NewAssociationWizard)this.getWizard()).getDataModel(); - } - - protected String getReferrerTableName(){ - return ((NewAssociationWizard)getWizard()).getReferrerTableName(); - } - - protected String getReferencedTableName(){ - return ((NewAssociationWizard)getWizard()).getReferencedTableName(); - } - - protected String getJoinTableName(){ - return ((NewAssociationWizard)getWizard()).getJoinTableName(); - } - - protected String getCardinality(){ - return ((NewAssociationWizard)getWizard()).getCardinality() ; - } - - public void updateWithNewTables() { - } - - /** - * Returns the helps system. - * @return The platform's help system - */ - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/PromptJPAProjectWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/PromptJPAProjectWizardPage.java deleted file mode 100644 index ef248f04ea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/PromptJPAProjectWizardPage.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.wizards.gen; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.PlatformUI; - -public class PromptJPAProjectWizardPage extends WizardPage { - - private static String SELECT_PROJECT_PAGE_NAME = "SelectJPAProject"; //$NON-NLS-1$ - private Table projTable; - private TableViewer projTableViewer; - private static int PROJECT_NAME_COLUMN_INDEX = 0; - private final String helpContextId; - - protected PromptJPAProjectWizardPage( final String helpContextId ) { - super(SELECT_PROJECT_PAGE_NAME); - setTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_selectJPAProject ); - setMessage( JptUiEntityGenMessages.GenerateEntitiesWizard_selectJPAProject_msg ); - this.helpContextId = helpContextId; - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 1; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - Label label = new Label( composite, SWT.NONE ); - label.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_selectJPAProject ); - - projTableViewer = new TableViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL); - projTable = projTableViewer.getTable(); - GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); - projTable.setLayoutData(gd); - - projTable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleJpaProjectSelection(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - }); - - projTableViewer = new TableViewer(projTable); - projTableViewer.setLabelProvider(new ProjectTableLabelProvider()); - projTableViewer.setContentProvider(new ProjectTableContentProvider()); - fillJpaProjectList(); - setControl( composite ); - validate(); - } - - private void handleJpaProjectSelection() { - if (projTable.getSelectionIndex() != -1) { - TableItem item = projTable.getItem(projTable.getSelectionIndex()); - String projName = item.getText(0); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); - JpaProject jpaProj = JptJpaCorePlugin.getJpaProject( project ); - ((GenerateEntitiesFromSchemaWizard)getWizard()).setJpaProject(jpaProj); - validate(); - } - } - - private void fillJpaProjectList() { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - List<String> projNames = new ArrayList<String>(); - for ( IProject project : projects ) - { - JpaProject jpaProj = JptJpaCorePlugin.getJpaProject( project ); - if ( jpaProj != null ) { - projNames.add(project.getName()); - } - } - projTableViewer.setInput(projNames); - } - - private void validate() { - if (projTable.getSelectionIndex() != -1) - setPageComplete(true); - else - setPageComplete(false); - } - - @Override - public final void performHelp() - { - PlatformUI.getWorkbench().getHelpSystem().displayHelp( this.helpContextId ); - } - - // inner classes - private final class ProjectTableLabelProvider extends LabelProvider implements ITableLabelProvider { - public Image getColumnImage(Object element, int columnIndex) - { - if (columnIndex == PROJECT_NAME_COLUMN_INDEX) - return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT); - return null; - } - - public String getColumnText(Object element, int columnIndex) - { - assert element instanceof String; - String projectName = (String)element; - if (columnIndex == PROJECT_NAME_COLUMN_INDEX) - return projectName; - return null; - } - } - - private final class ProjectTableContentProvider implements IStructuredContentProvider - { - public Object[] getElements(Object inputElement){ - return ((Collection<?>) inputElement).toArray(); - } - - public void dispose(){} - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput){} - - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/SWTUtil.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/SWTUtil.java deleted file mode 100644 index c295097241..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/SWTUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.jpa.ui.internal.wizards.gen; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * Collection of utility methods to create SWT UI - * - */ -public class SWTUtil { - /** - * Set the layoutData of the input control to occupy specified number of columns - * @param c - * @param columns - */ - public static void fillColumns(Control c, int columns){ - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - c.setLayoutData(layoutData); - return ; - } - - public static void fillColumnsWithIndent(Control c, int columns, int indent){ - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - layoutData.horizontalIndent = indent ; - c.setLayoutData(layoutData); - return ; - } - - public static Label createLabel(Composite container, int span, String text) { - Label label = new Label(container, SWT.NONE); - label.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - label.setLayoutData(gd); - return label; - } - - /** - * Create a new label which occupies one grid column - * @param parent - * @param text - */ - public static Label newLabel(Composite parent, String text) { - Label label = new Label( parent, SWT.NONE); - label.setText( text ); - label.setLayoutData(new GridData()); - return label; - } - - /** - * Create a new label which occupies one grid column - * @param parent - * @param text - */ - public static Label newLabelWithIndent(Composite parent, String text, int indent) { - Label label = new Label( parent, SWT.NONE); - label.setText( text ); - GridData layoutData = new GridData(); - layoutData.horizontalAlignment = SWT.BEGINNING; - layoutData.verticalAlignment = SWT.TOP ; - layoutData.horizontalIndent = indent ; - label.setLayoutData(layoutData); - return label; - } - - /** - * Creates a separator line. Expects a <code>GridLayout</code> with at least 1 column. - * - * @param composite the parent composite - * @param nColumns number of columns to span - */ - @SuppressWarnings("restriction") - public static void createSeparator(Composite composite, int nColumns) { - (new org.eclipse.jdt.internal.ui.wizards.dialogfields.Separator( - SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, 5); - } - - - public static Button createButton(Composite container, int span, String text, int style) { - Button btn = new Button(container, style); - btn.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - btn.setLayoutData(gd); - return btn; - } - - public static Combo createCombo(Composite container, int span ) { - Combo combo = new Combo(container, SWT.SINGLE | SWT.READ_ONLY); - GridData gd = new GridData(); - gd.horizontalSpan = span; - gd.grabExcessHorizontalSpace=true; - gd.horizontalAlignment = SWT.FILL; - combo.setLayoutData(gd); - return combo; - } - - public static Text createText(Composite container, int span ) { - Text text = new Text(container, SWT.BORDER); - GridData gd = new GridData(); - gd.horizontalSpan = span; - gd.grabExcessHorizontalSpace=true; - gd.horizontalAlignment = SWT.FILL; - text.setLayoutData(gd); - return text; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/SelectTableDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/SelectTableDialog.java deleted file mode 100644 index f9b9ee0d97..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/SelectTableDialog.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ElementListSelectionDialog; - -/** - * A database table selection dialog which allows user to filter tables by name - */ -public class SelectTableDialog extends ElementListSelectionDialog { - - public SelectTableDialog(Shell shell, final ResourceManager resourceManager){ - super(shell, new ILabelProvider(){ - public Image getImage(Object element) { - return ImageRepository.getTableImage(resourceManager); - } - - public String getText(Object element) { - return element.toString(); - } - public void addListener(ILabelProviderListener listener) {} - public void dispose() {} - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) {} - - }); - this.setTitle( JptUiEntityGenMessages.selectTableDlgTitle );// - this.setMessage( JptUiEntityGenMessages.selectTableDlgDesc);// - } - - public SelectTableDialog(Shell shell, ResourceManager resourceManager, Schema schema){ - this(shell, resourceManager); - - ArrayList<String> list = new ArrayList<String>(); - for (Table table : schema.getTables()) { - list.add(table.getName()); - } - this.setElements( list.toArray() ); - - } - - public SelectTableDialog(Shell shell, ResourceManager resourceManager, List<String> tableNames){ - this(shell, resourceManager); - this.setElements( tableNames.toArray() ); - } - - public String getSelectedTable() { - String tableName = (String)this.getFirstResult(); - return tableName ; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableAssociationsWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableAssociationsWizardPage.java deleted file mode 100644 index 51663f6159..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableAssociationsWizardPage.java +++ /dev/null @@ -1,775 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - - -import static org.eclipse.jpt.jpa.ui.internal.wizards.gen.SWTUtil.fillColumns; -import static org.eclipse.jpt.jpa.ui.internal.wizards.gen.SWTUtil.newLabel; -import static org.eclipse.jpt.jpa.ui.internal.wizards.gen.SWTUtil.newLabelWithIndent; - -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; -import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; -import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; -import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; -import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.gen.internal.Association; -import org.eclipse.jpt.jpa.gen.internal.AssociationRole; -import org.eclipse.jpt.jpa.gen.internal.ORMGenColumn; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.FillLayout; -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.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - -public class TableAssociationsWizardPage extends WizardPage { - - private JpaProject jpaProject; - private ORMGenCustomizer customizer ; - - private AssociationsListComposite associationList; - private Association selectedAssociation; - private Button deleteAssociationLink ; - private Button createAssociationLink ; - - //Controls in Association Edit Panel - private Composite associationsEditPanel ; - private Button generateAssociationCheckBox; - private Label cardinalityLabel ; - private Combo cardinalityCombo ; - /*whether to generate the referrer-->referenced role.*/ - private Button referrerRoleCheckBox; - /*the name of the property in the referrer-->referenced role.*/ - private Label referrerRolePropertyLabel; - private Text referrerRolePropertyField ; - /*the cascade in the referrer-->referenced role.*/ - @SuppressWarnings("restriction") - private StringButtonDialogField referrerRoleCascadeField; - /*whether to generate the referenced->referrer role.*/ - private Button referencedRoleCheckBox; - /*the name of the property in the referenced->referrer role.*/ - private Label referencedRolePropertyLabel; - private Text referencedRolePropertyField ; - /*the cascade in the referenced->referrer role.*/ - @SuppressWarnings("restriction") - private StringButtonDialogField referencedRoleCascadeField; - private Label joinConditionLabel; - private Text joinConditionText; - - private Composite detailPanel; - private StackLayout detailPanelStatckLayout; - private Composite emptyPanel; - - protected final ResourceManager resourceManager; - - protected TableAssociationsWizardPage(JpaProject jpaProject, ResourceManager resourceManager) { - super("Table Associations"); //$NON-NLS-1$ - this.jpaProject = jpaProject; - this.resourceManager = resourceManager; - setTitle(JptUiEntityGenMessages.GenerateEntitiesWizard_assocPage_title); - setMessage(JptUiEntityGenMessages.GenerateEntitiesWizard_assocPage_desc); - - } - - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 2 ; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_TABLE_ASSOCIATIONS); - - Label label = new Label(composite, SWT.NONE); - label.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_assocPage_label ); - GridData gd = new GridData(); - gd.horizontalSpan = 2; - label.setLayoutData( gd ); - - createAssociationsListPanel(composite); - createAddDeleteButtons(composite, nColumns); - SWTUtil.createSeparator(composite, nColumns); - - createDetailPanel(composite); - setControl(composite); - - composite.layout(true); - this.setPageComplete( true); - - } - - private void createAddDeleteButtons(Composite composite, int columns) { - - Composite c = new Composite( composite, SWT.NONE); - fillColumns(c, 1); - c.setLayout( new GridLayout(1,true) ); - - createAssociationLink = new Button(c, SWT.NONE); - createAssociationLink.setToolTipText( JptUiEntityGenMessages.GenerateEntitiesWizard_assocPage_newAssoc ); - createAssociationLink.setImage( ImageRepository.getAddButtonImage(this.resourceManager) ); - createAssociationLink.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - launchNewAssociationsWizard(); - } - - }); - - deleteAssociationLink = new Button(c, SWT.NONE); - Color foreground = new Color(Display.getDefault(), 0,0,255); - deleteAssociationLink.setForeground(foreground); - foreground.dispose(); - deleteAssociationLink.setImage( ImageRepository.getDeleteButtonImage(this.resourceManager)); - deleteAssociationLink.setToolTipText( JptUiEntityGenMessages.GenerateEntitiesWizard_assocPage_delAssoc ); - deleteAssociationLink.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - Association association = associationList.getSelectedAssociation(); - if( association != null ){ - ORMGenCustomizer customizer = getCustomizer(); - customizer.deleteAssociation(association); - List<Association> associations = customizer.getAssociations(); - associationList.updateAssociations(associations); - if( associations.size()==0 ){ - hideAssociationDetail(); - } - } - } - }); - deleteAssociationLink.setEnabled(false); - - } - - private void createGenerateAssociationCheckbox(Composite composite, int columns) { - generateAssociationCheckBox = new Button(composite, SWT.CHECK); - generateAssociationCheckBox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_genAssoc); - generateAssociationCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - Association association = associationList.getSelectedAssociation(); - if( association == null ) - return; - association.setGenerated(generateAssociationCheckBox.getSelection()); - - updateAssociationEditPanel(association); - associationList.updateSelectedAssociation(); - } - - }); - - fillColumns(generateAssociationCheckBox, columns-1); - newLabel(composite, ""); - } - - @SuppressWarnings("restriction") - private void createGenerateReferrerRoleControls(Composite parent, int columns) { - referrerRoleCheckBox = new Button(parent, SWT.CHECK); - referrerRoleCheckBox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_entityRef ); - referrerRoleCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - boolean generate = referrerRoleCheckBox.getSelection(); - //referrerRolePropertyField.setEditable( generate ); - referrerRolePropertyLabel.setEnabled( generate ); - referrerRolePropertyField.setEnabled( generate ); - referrerRoleCascadeField.setEnabled(generate); - - //If both referencedRoleCheckBox and referencedRoleCheckBox unchecked, - //the association itself shouldn't be generated - if( !generate && !referencedRoleCheckBox.getSelection()){ - generateAssociationCheckBox.setSelection(false); - cardinalityLabel.setEnabled( false ); - cardinalityCombo.setEnabled(false); - referrerRoleCheckBox.setEnabled(false); - referencedRoleCheckBox.setEnabled(false); - } - - directionalityCheckBoxChanged( ); - - if( generate ){ - AssociationRole role = selectedAssociation.getReferrerRole(); - referrerRolePropertyField.setText( role.getPropertyName() ); - } - } - - }); - - SWTUtil.fillColumnsWithIndent(referrerRoleCheckBox , columns-1, 20 ); - newLabel(parent, "");//$NON-NLS-1$ - - referrerRolePropertyLabel = newLabelWithIndent( parent, JptUiEntityGenMessages.property, 40 ); - referrerRolePropertyField = new Text( parent, SWT.BORDER); - fillColumns(referrerRolePropertyField, 2); - referrerRolePropertyField.addModifyListener(new ModifyListener(){ - @SuppressWarnings("deprecation") - public void modifyText(ModifyEvent e) { - if( selectedAssociation.getReferrerRole() == null ) - return; - String fieldName = referrerRolePropertyField.getText(); - IStatus status = JavaConventions.validateFieldName( fieldName ); - if( !status.matches(IStatus.ERROR) ){ - selectedAssociation.getReferrerRole().setPropertyName(fieldName); - } - updateStatus(status); - } - }); - - Label label = new Label( parent, SWT.NONE); - label.setText( "" );//$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); - - referrerRoleCascadeField = new StringButtonDialogField( new IStringButtonAdapter(){ - public void changeControlPressed(DialogField field) { - if( editCascade( selectedAssociation.getReferrerRole() )){ - referrerRoleCascadeField.setText(selectedAssociation.getReferrerRole().getCascade()); - } - } - }) ; - referrerRoleCascadeField.setLabelText( JptUiEntityGenMessages.cascade ); - referrerRoleCascadeField.setButtonLabel(""); //$NON-NLS-1$ - referrerRoleCascadeField.doFillIntoGrid(parent, 3); - referrerRoleCascadeField.getTextControl(parent).setEditable(false); - int maxFieldWidth = convertWidthInCharsToPixels(40); - LayoutUtil.setWidthHint(referrerRoleCascadeField.getTextControl(null), maxFieldWidth ); - Button btn = referrerRoleCascadeField.getChangeControl(null); - GridData data = (GridData)btn.getLayoutData(); - btn.setImage( ImageRepository.getBrowseButtonImage(this.resourceManager) ); - data.horizontalAlignment = SWT.BEGINNING; - data.widthHint = 30; - btn.setLayoutData(data); - - Label labelCtrl = referrerRoleCascadeField.getLabelControl(parent); - data = (GridData)labelCtrl.getLayoutData(); - data.horizontalIndent = 40 ; - labelCtrl.setLayoutData(data); - - - label = new Label( parent, SWT.NONE); - label.setText( "" );//$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); - - } - - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if( visible ){ - hideAssociationDetail(); - updateAssociationsListPanel(); - } - } - - private void hideAssociationDetail( ){ - this.detailPanelStatckLayout.topControl = emptyPanel; - this.detailPanel.layout(); - this.detailPanel.getParent().layout(); - } - - /** - * Updates the status line and the OK button according to the given status - * - * @param status status to apply - */ - @SuppressWarnings("restriction") - protected void updateStatus(IStatus status) { - setPageComplete(!status.matches(IStatus.ERROR)); - - StatusUtil.applyToStatusLine(this, status); - if( status.getCode() == Status.OK ){ - setMessage(JptUiEntityGenMessages.GenerateEntitiesWizard_assocPage_desc); - } - } - - @SuppressWarnings("restriction") - private void createGenerateReferencedRoleControls(Composite parent, int columns) { - referencedRoleCheckBox = new Button(parent, SWT.CHECK); - referencedRoleCheckBox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_setRef ); - referencedRoleCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - boolean generate = referencedRoleCheckBox.getSelection(); - referencedRolePropertyLabel.setEnabled( generate); - referencedRolePropertyField.setEnabled( generate); - referencedRoleCascadeField.setEnabled(generate); - - if( !generate && !referrerRoleCheckBox.getSelection()){ - generateAssociationCheckBox.setSelection(false); - cardinalityCombo.setEnabled(false); - referrerRoleCheckBox.setEnabled(false); - referencedRoleCheckBox.setEnabled(false); - } - directionalityCheckBoxChanged(); - if( generate ){ - AssociationRole role = selectedAssociation.getReferencedRole(); - referencedRolePropertyField.setText( role.getPropertyName() ); - } - } - - }); - - SWTUtil.fillColumnsWithIndent( referencedRoleCheckBox , columns-1, 20 ); - newLabel(parent, "");//$NON-NLS-1$ - - referencedRolePropertyLabel = SWTUtil.newLabelWithIndent(parent, JptUiEntityGenMessages.property, 40 ); - - referencedRolePropertyField = new Text( parent, SWT.BORDER); - fillColumns(referencedRolePropertyField, 2); - referencedRolePropertyField.addModifyListener(new ModifyListener(){ - public void modifyText(ModifyEvent e) { - if( selectedAssociation.getReferencedRole() == null ) - return ; - - String fieldName = referencedRolePropertyField.getText(); - IStatus status = JavaConventions.validateIdentifier(fieldName, - JavaCore.VERSION_1_3, JavaCore.VERSION_1_3); - if( !status.matches(IStatus.ERROR) ){ - if( !fieldName.equals(selectedAssociation.getReferencedRole().getPropertyName()) ) - selectedAssociation.getReferencedRole().setPropertyName(fieldName); - } - updateStatus(status); - } - }); - - - Label label = new Label( parent, SWT.NONE); - label.setText( "" );//$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); - - - referencedRoleCascadeField = new StringButtonDialogField( new IStringButtonAdapter(){ - public void changeControlPressed(DialogField field) { - if( editCascade( selectedAssociation.getReferencedRole() ) ){ - referencedRoleCascadeField.setText( selectedAssociation.getReferencedRole().getCascade() ); - } - } - }) ; - referencedRoleCascadeField.setLabelText( JptUiEntityGenMessages.cascade ); - referencedRoleCascadeField.setButtonLabel(""); //$NON-NLS-1$ - referencedRoleCascadeField.doFillIntoGrid(parent, 3); - referencedRoleCascadeField.getTextControl(parent).setEditable( false); - int maxFieldWidth = convertWidthInCharsToPixels(40); - LayoutUtil.setWidthHint(referencedRoleCascadeField.getTextControl(null), maxFieldWidth ); - Button btn = referencedRoleCascadeField.getChangeControl(null); - btn.setImage( ImageRepository.getBrowseButtonImage(this.resourceManager) ); - GridData data = (GridData)btn.getLayoutData(); - data.horizontalAlignment = SWT.BEGINNING; - data.widthHint = 30; - btn.setLayoutData(data); - - Label labelCtrl = referencedRoleCascadeField.getLabelControl(parent); - data = (GridData)labelCtrl.getLayoutData(); - data.horizontalIndent = 40 ; - labelCtrl.setLayoutData(data); - - label = new Label( parent, SWT.NONE); - label.setText( "" );//$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); - - } - - private void createDetailPanel(Composite composite ) { - - this.detailPanel = new Composite( composite, SWT.NONE); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.grabExcessVerticalSpace = false; - this.detailPanel.setLayoutData(gd); - this.detailPanelStatckLayout = new StackLayout(); - this.detailPanel.setLayout( this.detailPanelStatckLayout ); - - emptyPanel = new Composite( detailPanel, SWT.NONE); - emptyPanel.setLayoutData(new GridData()); - detailPanelStatckLayout.topControl = emptyPanel; - detailPanel.layout(); - - composite.layout(); - } - - - private Composite createAssociationsEditPanel(Composite composite, int columns) { - Composite parent = new Composite( composite, SWT.NONE); - fillColumns(parent, 4); - - createGenerateAssociationCheckbox(parent,columns); - int nColumns= 4 ; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - parent.setLayout(layout); - - //Cardinality - cardinalityLabel = new Label(parent, SWT.NONE); - cardinalityLabel.setText( JptUiEntityGenMessages.cardinality); - GridData gd = new GridData(); - gd.horizontalIndent = 20; - cardinalityLabel.setLayoutData( gd ); - - cardinalityCombo = new Combo(parent, SWT.SINGLE | SWT.READ_ONLY ); - - fillColumns(cardinalityCombo, 1); - - cardinalityCombo.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - selectedAssociation.setCardinality( cardinalityCombo.getText()); - associationList.updateSelectedAssociation(); - } - }); - - //Adding a filler column - Label label = new Label( parent, SWT.NONE); - label.setText( "");//$NON-NLS-1$ - GridData layoutData = new GridData(); - layoutData.horizontalSpan = 2; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - label.setLayoutData(layoutData); - - //Table join condition - joinConditionLabel = newLabelWithIndent(parent, JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_tableJoin, 20 ); - - joinConditionText = new Text( parent, SWT.MULTI | SWT.BORDER ); - joinConditionText.setEditable(false); - joinConditionText.setText(JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_joinedWhen); - layoutData = new GridData(); - layoutData.horizontalSpan = 2; - layoutData.verticalAlignment = SWT.TOP; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - layoutData.heightHint = 50; - joinConditionText.setLayoutData(layoutData); - newLabel(parent, "");//$NON-NLS-1$ - - //Generate UI controls for ReferrerRole - createGenerateReferrerRoleControls(parent, columns); - - //Generate UI controls for ReferencedRole - createGenerateReferencedRoleControls(parent, columns); - - - return parent; - } - - public boolean editCascade(AssociationRole role) { - CascadeDialog dlg = CascadeDialog.create(role); - if (dlg.open() == Window.CANCEL ) { - return false; - } - - return true; - } - - private void createAssociationsListPanel(Composite parent) { - Composite composite = new Composite( parent, SWT.NULL ); - composite.setLayout( new FillLayout()); - Color backgroundColor = new Color(Display.getDefault(),255, 0,0); - composite.setBackground(backgroundColor); - backgroundColor.dispose(); - GridData layoutData = new GridData(); - layoutData.horizontalSpan = 1; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = false; - layoutData.grabExcessVerticalSpace = true; - layoutData.widthHint = 400; - layoutData.heightHint = 400; - composite.setLayoutData(layoutData); - - associationList = new AssociationsListComposite(composite, this, this.resourceManager); - } - - private void launchNewAssociationsWizard() { - ORMGenCustomizer customizer = getCustomizer(); - NewAssociationWizard wizard = new NewAssociationWizard(this.jpaProject, customizer, this.resourceManager); - - WizardDialog dialog = new WizardDialog( this.getShell(), wizard); - dialog.create(); - int returnCode = dialog.open(); - if (returnCode == Window.OK) { - Association association = wizard.getNewAssociation(); - if( association !=null ){ - customizer.addAssociation(association); - updateForeignKeyColumnGenProperty(association); - updateAssociationsListPanel(); - } - } - } - /** - * For user created association: - * If association is to be generated, no need to generate the getter/setter for the column itself - */ - private void updateForeignKeyColumnGenProperty(Association association) { - //Need to process MANY_TO_ONE only since the the associations list are optimized to have MANY_TO_ONE - if( association.isCustom() && association.getCardinality().equals( Association.MANY_TO_ONE ) ){ - boolean generateColumn = !association.isGenerated(); - //The "MANY" side DB table - //ORMGenTable table1 = association.getReferrerTable(); - //The "ONE" side DB table - //ORMGenTable table2 = association.getReferencedTable(); - //The list of foreign key columns in the MANY side, should not be generated - //The list of primary keys in the ONE side, will be generated - //List<ORMGenColumn> list2 = association.getReferencedColumns(); - List<ORMGenColumn> list1 = association.getReferrerColumns(); - for(ORMGenColumn c : list1 ){ - if( c.isGenerated() != generateColumn){ - if( !generateColumn && c.getDbColumn().isPartOfPrimaryKey() ){ - continue; - } - c.setGenerated(generateColumn); - c.setInsertable(generateColumn); - c.setUpdateable(generateColumn); - } - } - } - } - - private void updateAssociationsListPanel() { - ORMGenCustomizer customizer = getCustomizer(); - //If user changed the connection or schema - if( this.customizer != customizer ){ - this.customizer = customizer; - } - List<Association> associations = customizer.getAssociations(); - this.associationList.updateAssociations( associations ); - } - - @SuppressWarnings("restriction") - public void updateAssociationEditPanel(Association association) { - this.selectedAssociation = association; - - boolean enabled = association.isCustom(); - this.deleteAssociationLink.setEnabled(enabled); - - //Create and display the associationsEditPanel if it was hidden before - if( associationsEditPanel == null ){ - associationsEditPanel = this.createAssociationsEditPanel(this.detailPanel, 4); - } - this.detailPanelStatckLayout.topControl = associationsEditPanel; - this.detailPanel.layout(); - this.detailPanel.getParent().layout(); - - //Update the UI controls from the model - String table1Name = association.getReferrerTableName(); - String table2Name = association.getReferencedTableName(); - String joinTableName = association.getJoinTableName(); - - boolean isGenerated = association.isGenerated(); - this.generateAssociationCheckBox.setSelection(isGenerated); - this.referrerRolePropertyLabel.setEnabled( isGenerated ); - this.referrerRolePropertyField.setEnabled( isGenerated ); - this.referrerRoleCheckBox.setEnabled( isGenerated ); - this.referencedRolePropertyLabel.setEnabled( isGenerated ); - this.referencedRolePropertyField.setEnabled( isGenerated ); - this.referencedRoleCheckBox.setEnabled( isGenerated ); - this.cardinalityLabel.setEnabled(isGenerated); - this.cardinalityCombo.setEnabled(isGenerated); - this.joinConditionLabel.setEnabled( isGenerated ); - this.joinConditionText.setEnabled( isGenerated ); - - String cardinality = association.getCardinality(); - if( Association.MANY_TO_MANY.equals( cardinality ) ){ - cardinalityCombo.removeAll(); - cardinalityCombo.add( Association.MANY_TO_MANY); - }else{ - cardinalityCombo.removeAll(); - cardinalityCombo.add( Association.MANY_TO_ONE); - cardinalityCombo.add( Association.ONE_TO_ONE); - } - - cardinalityCombo.setText(cardinality); - cardinalityCombo.setEnabled(enabled); - - String text = null; - //if MTM - if( Association.MANY_TO_MANY.equals( cardinality ) ){ - text = String.format( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_setRef, table2Name, table1Name); - }else{ - text = String.format( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_entityRef, table2Name, table1Name); - } - this.referrerRoleCheckBox.setText(text); - - //if OTO - if( Association.ONE_TO_ONE.equals( cardinality ) ){ - text = String.format( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_entityRef, table1Name, table2Name); - }else{ - text = String.format( JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_setRef, table1Name, table2Name); - } - this.referencedRoleCheckBox.setText(text); - - //AssociationRole properties - AssociationRole referrerRole = association.getReferrerRole(); - if( referrerRole != null){ - this.referrerRoleCheckBox.setSelection( true ); - this.referrerRolePropertyField.setEditable(true); - this.referrerRolePropertyField.setText(referrerRole.getPropertyName()); - this.referrerRoleCascadeField.setEnabled(true); - String cascade = referrerRole.getCascade(); - if( cascade!=null ) - this.referrerRoleCascadeField.setText( cascade ); - - //if MTO: - if( Association.MANY_TO_ONE.equals( cardinality ) ){ - this.referrerRoleCheckBox.setEnabled( false ); - } - }else{ - this.referrerRoleCheckBox.setSelection( false ); - this.referrerRolePropertyLabel.setEnabled(false); - this.referrerRolePropertyField.setEditable(false); - this.referrerRolePropertyField.setText(""); - this.referrerRoleCascadeField.setEnabled(false); - } - - AssociationRole referencedRole = association.getReferencedRole(); - if( referencedRole != null){ - this.referencedRoleCheckBox.setSelection( true ); - this.referencedRolePropertyLabel.setEnabled(true); - this.referencedRolePropertyField.setEditable(true); - this.referencedRolePropertyField.setText(referencedRole.getPropertyName()); - this.referencedRoleCascadeField.setEnabled(true); - String cascade = referencedRole.getCascade(); - if( cascade!=null ) - this.referencedRoleCascadeField.setText(cascade); - }else{ - this.referencedRoleCheckBox.setSelection( false ); - this.referencedRolePropertyLabel.setEnabled(false); - this.referencedRolePropertyField.setEditable(false); - this.referencedRolePropertyField.setText(""); - this.referencedRoleCascadeField.setEnabled(false); - } - - //Join conditions - updateJoinConditions(association, table1Name, table2Name, joinTableName); - } - - private void updateJoinConditions(Association association, - String table1Name, String table2Name, String joinTableName) { - String text = "%s"; - if( joinTableName == null ){ - StringBuilder strText = new StringBuilder(); - //text = JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_joinedWhen; - List<String> columnList1 = association.getReferrerColumnNames() ; - List<String> columnList2 = association.getReferencedColumnNames(); - for( int i=0; i < columnList1.size(); i++){ - strText.append( table1Name + "." + columnList1.get(i) );//$NON-NLS-1$ - strText.append( "=" );//$NON-NLS-1$ - strText.append( table2Name + "." + columnList2.get(i) );//$NON-NLS-1$ - if( i < columnList1.size()-1 ) - strText.append( "\n AND " );//$NON-NLS-1$ - } - joinConditionText.setText( String.format( text , strText.toString()) ); - }else{ - StringBuilder strText = new StringBuilder(); - //text = JptUiEntityGenMessages.GenerateEntitiesWizard_assocEditor_joinedWhen; - List<String> columnList1 = association.getReferrerColumnNames() ; - List<String> joinColumnList1 = association.getReferrerJoinColumnNames() ; - for( int i=0; i < columnList1.size(); i++){ - strText.append( table1Name + "." + columnList1.get(i) );//$NON-NLS-1$ - strText.append( "=" );//$NON-NLS-1$ - strText.append( joinTableName + "." + joinColumnList1.get(i) ); - strText.append( "\n AND " );//$NON-NLS-1$ - } - - List<String> joinTableColumnList2 = association.getReferencedJoinColumnNames(); - List<String> columnList2 = association.getReferencedColumnNames(); - for( int i=0; i < joinTableColumnList2.size(); i++){ - strText.append( joinTableName + "." + joinTableColumnList2.get(i) ); - strText.append( "=" );//$NON-NLS-1$ - strText.append( table2Name + "." + columnList2.get(i) );//$NON-NLS-1$ - if( i < joinTableColumnList2.size()-1 ) - strText.append( "\n AND " );//$NON-NLS-1$ - } - - joinConditionText.setText( String.format( text , strText.toString()) ); - - } - } - - /** - * Called when one of referrerRoleCheckBox or referencedRoleCheckBox - * changes value. - * - */ - private void directionalityCheckBoxChanged() { - String dir; - if (referrerRoleCheckBox.getSelection()) { - dir = referencedRoleCheckBox.getSelection() ? Association.BI_DI : Association.NORMAL_DI; - } else { - if (referencedRoleCheckBox.getSelection()) { - dir = Association.OPPOSITE_DI; - } else { - dir = null; - } - } - if (dir != null) { - selectedAssociation.setDirectionality(dir); - } else { - selectedAssociation.setGenerated(false); - } - - this.associationList.updateSelectedAssociation(); - } - - private ORMGenCustomizer getCustomizer(){ - GenerateEntitiesFromSchemaWizard wizard = (GenerateEntitiesFromSchemaWizard) this.getWizard(); - return wizard.getCustomizer(); - } - - - @Override - public final void performHelp() - { - this.getHelpSystem().displayHelp( GenerateEntitiesFromSchemaWizard.HELP_CONTEXT_ID ); - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } - - @Override - public void dispose() { - //when the JPA project wizard page is shown first, the other wizard pages are lazily built, thus - //associationList can be null - bug 307894 - if (this.associationList != null) { - this.associationList.dispose(); - } - super.dispose(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableFigure.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableFigure.java deleted file mode 100644 index 7cf16fa95c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableFigure.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.GridLayout; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - -/** - * A draw2D figure representing a database table - * - */ -public class TableFigure extends Figure -{ - private Color tableColor = new Color(null, 220, 232, 241); - - private Font tableFont = new Font(null, "Arial", 8, SWT.NONE); //$NON-NLS-1$ - - private Color borderColor = new Color(null, 14, 66, 115); - - public static final int OUTLINE_CORNER_RADIUS = 6; - - protected final ResourceManager resourceManager; - - public TableFigure(String name, ResourceManager resourceManager) { - this.resourceManager = resourceManager; - GridLayout gl = new GridLayout(); - gl.marginHeight = 2; - gl.marginWidth = 10; - setLayoutManager(gl); - setBorder(new LineBorder(this.tableColor, 0)); - setBackgroundColor(this.tableColor); - setOpaque(true); - setSize(150, 20); - Label nameLabel = new Label("", ImageRepository.getTableObjImage(this.resourceManager)); - nameLabel.setFont(this.tableFont); - nameLabel.setText(name); - nameLabel.setForegroundColor(this.borderColor); - nameLabel.setLabelAlignment(PositionConstants.CENTER); - add(nameLabel); - } - - @Override - protected void paintClientArea(Graphics graphics) { - super.paintClientArea(graphics); - graphics.pushState(); - Rectangle r = getBounds().getCopy(); - graphics.drawRoundRectangle(r.expand(new Insets(-1, -1, -2, -2)), OUTLINE_CORNER_RADIUS, OUTLINE_CORNER_RADIUS); - graphics.popState(); - } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (enabled) { - setBackgroundColor(this.tableColor); - } - else { - setBackgroundColor(ColorConstants.white); - } - } - - public void dispose() { - this.borderColor.dispose(); - this.tableFont.dispose(); - this.tableColor.dispose(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableGenPanel.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableGenPanel.java deleted file mode 100644 index 926e72b0a5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TableGenPanel.java +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.jpa.gen.internal.ORMGenTable; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * The UI panel for setting the default and specific - * table entity generation properties. - * - */ -class TableGenPanel -{ - WizardPage wizardPage ; - - private Text classNameField; // used in setting individual table/entity generation only - - private Combo idGeneratorCombo; - private Text sequenceNameField; - - private Button entityAccessField; - private Button entityAccessProperty; - private Button associationFetchDefault; - private Button associationFetchEager; - private Button associationFetchLazy; - - private Button collectionTypeSet; - private Button collectionTypeList; - - private Button generateOptionalAnnotations; - - private Label sequenceNameNoteLabel; - - private boolean isUpdatingControls; - - private ORMGenTable mTable; - - private boolean isDefaultTable = false; - - public TableGenPanel(Composite parent, int columns , boolean isDefaultTable, WizardPage wizardPage ){ - super(); - this.wizardPage = wizardPage; - this.isDefaultTable = isDefaultTable; - createTableMappingPropertiesGroup(parent, columns); - SWTUtil.createLabel(parent, 4, ""); //$NON-NLS-1$ - } - - protected void createTableMappingPropertiesGroup(Composite composite, int columns) { - Group parent = new Group(composite, SWT.NONE ); - parent.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_tableMapping); - parent.setLayout(new GridLayout(columns, false)); - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - parent.setLayoutData(layoutData); - - createClassNameControl(parent, columns); - - createIdGeneratorControls(parent, columns); - createEntityAccessControls(parent, columns); - - //AssociationFetch and CollectionType only available for default table generation - if ( isDefaultTable ) { - createAssociationFetchControls(parent, columns); - createCollectionTypeControls(parent, columns); - createGenerateOptionalAnnotationControls(parent, columns); - } - } - - private void createGenerateOptionalAnnotationControls(Group parent, int columns) { - generateOptionalAnnotations = new Button(parent, SWT.CHECK ); - generateOptionalAnnotations.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_genOptionalAnnotations); - generateOptionalAnnotations.setToolTipText(JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_genOptionalAnnotations_desc); - - GridData gd = new GridData(); - gd.horizontalSpan = columns; - generateOptionalAnnotations.setLayoutData(gd); - generateOptionalAnnotations.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - boolean selected = generateOptionalAnnotations.getSelection(); - mTable.setGenerateDDLAnnotations(selected); - } - }); - } - - private void createClassNameControl(Composite parent, int columns) { - //Customize class name for specific table only - if ( !isDefaultTable ) { - SWTUtil.createLabel( parent, 1 , JptUiEntityGenMessages.GenerateEntitiesWizard_tablePanel_className ); - - classNameField = new Text(parent, SWT.SINGLE | SWT.BORDER ); - //mPackageNameField.setEditable(false); - SWTUtil.fillColumns(classNameField,3); - classNameField.addModifyListener(new ModifyListener(){ - @SuppressWarnings({ "deprecation" }) - public void modifyText(ModifyEvent e) { - if (e.getSource() == null || !isUpdatingControls) { - String className = classNameField.getText(); - IStatus status = JavaConventions.validateJavaTypeName( className ); - if( !status.matches(IStatus.ERROR) ){ - mTable.setClassName( className ); - wizardPage.setErrorMessage(null); - }else{ - wizardPage.setErrorMessage(status.getMessage()); - } - } - } - }); - } - } - - class AssociationFetchListener implements SelectionListener{ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!isUpdatingControls) { - Button radioBtn = (Button)e.getSource(); - mTable.setDefaultFetch( radioBtn.getData().toString()); - } - } - } - - private void createAssociationFetchControls(Composite composite, int columns) { - SWTUtil.createLabel(composite, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_fetch ); - - Composite parent = new Composite( composite, SWT.NONE); - parent.setLayout(new RowLayout()); - SWTUtil.fillColumns( parent , 3); - associationFetchDefault = new Button( parent, SWT.RADIO ); - associationFetchDefault.setText( "Default"); - associationFetchDefault.setData( ORMGenTable.DEFAULT_FETCH ); - - associationFetchEager = new Button( parent, SWT.RADIO ); - associationFetchEager.setText( "&Eager"); - associationFetchEager.setData( ORMGenTable.EAGER_FETCH ); - - associationFetchLazy = new Button( parent, SWT.RADIO ); - associationFetchLazy.setText( "La&zy"); - associationFetchLazy.setData( ORMGenTable.LAZY_FETCH ); - - AssociationFetchListener associationFetchListener = new AssociationFetchListener(); - associationFetchDefault.addSelectionListener( associationFetchListener ); - associationFetchLazy.addSelectionListener( associationFetchListener ); - associationFetchEager.addSelectionListener( associationFetchListener ); - } - - class CollectionTypeListener implements SelectionListener { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!isUpdatingControls) { - Button radioBtn = (Button)e.getSource(); - mTable.setDefaultCollectionType( radioBtn.getData().toString()); - } - } - } - - private void createCollectionTypeControls(Composite composite, int columns) { - SWTUtil.createLabel(composite, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_collType ); - - Composite parent = new Composite( composite, SWT.NONE); - parent.setLayout(new RowLayout()); - SWTUtil.fillColumns( parent , 3); - - this.collectionTypeSet = new Button( parent, SWT.RADIO); - this.collectionTypeSet.setText( "java.util.Se&t"); - this.collectionTypeSet.setData( ORMGenTable.SET_COLLECTION_TYPE ); - this.collectionTypeList = new Button( parent, SWT.RADIO); - this.collectionTypeList.setText("java.util.&List"); - this.collectionTypeList.setData(ORMGenTable.LIST_COLLECTION_TYPE); - - CollectionTypeListener collectionTypeListener = new CollectionTypeListener(); - collectionTypeList.addSelectionListener( collectionTypeListener ); - collectionTypeSet.addSelectionListener( collectionTypeListener ); - } - - - public void setORMGenTable(ORMGenTable table) { - mTable = table; - - isUpdatingControls = true; - - try { - //ClassNameField is not available for default table - if(classNameField!= null ) - classNameField.setText( mTable.getClassName() ); - - final List<String> schemes = this.mTable.getCustomizer().getAllIdGenerators(); - String[] values = new String[schemes.size()]; - schemes.toArray(values); - idGeneratorCombo.setItems( values ); - String idGenerator = mTable.getIdGenerator(); - idGeneratorCombo.setText( idGenerator); - - boolean isSequence = this.mTable.getCustomizer().getSequenceIdGenerators().contains(idGenerator); - String sequenceName = mTable.isDefaultsTable() ? mTable.getSequence() : mTable.getFormattedSequence(); - sequenceName = ( sequenceName == null ? "" : sequenceName ); - sequenceNameField.setText( sequenceName ); - if ( isSequence ) { - sequenceNameField.setEnabled(true); - sequenceNameNoteLabel.setEnabled(true); - } else { - sequenceNameField.setEnabled(false); - sequenceNameNoteLabel.setEnabled(false); - } - - String access = mTable.getAccess() ; - if ( ORMGenTable.FIELD_ACCESS.equals( access ) ) { - this.entityAccessField.setSelection( true ); - this.entityAccessProperty.setSelection( false ); - } else { - this.entityAccessProperty.setSelection( true ); - this.entityAccessField.setSelection( false ); - } - - if (associationFetchLazy != null && associationFetchEager != null ) { - String defaultFetch = mTable.getDefaultFetch(); - //reset all three buttons - associationFetchDefault.setSelection(false); - associationFetchEager.setSelection(false); - associationFetchLazy.setSelection(false); - if( ORMGenTable.DEFAULT_FETCH.equals( defaultFetch ) ) - associationFetchDefault.setSelection(true); - else if( ORMGenTable.EAGER_FETCH.equals( defaultFetch ) ) - associationFetchEager.setSelection(true); - else - associationFetchLazy.setSelection(true); - } - - //DefaultTable only - if (collectionTypeList != null) { - String cType = mTable.getDefaultCollectionType(); - if ( ORMGenTable.LIST_COLLECTION_TYPE.equals( cType ) ) { - this.collectionTypeList.setSelection( true ); - this.collectionTypeSet.setSelection( false ); - } else { - this.collectionTypeSet.setSelection( true ); - this.collectionTypeList.setSelection( false ); - } - - this.generateOptionalAnnotations.setSelection( mTable.isGenerateDDLAnnotations()); - } - - } catch (Exception e) { - JptJpaUiPlugin.log(e); - } - - isUpdatingControls = false; - } - - private void createIdGeneratorControls(Composite parent, int columns) { - SWTUtil.createLabel(parent, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_keyGen ); - - idGeneratorCombo = new Combo(parent,SWT.SINGLE | SWT.READ_ONLY); - SWTUtil.fillColumns(idGeneratorCombo, 3); - - idGeneratorCombo.addSelectionListener( new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - if (isUpdatingControls) { - return; - } - - idGenChanged(); - }}); - - SWTUtil.createLabel(parent, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_sequence ); - sequenceNameField = new Text( parent, SWT.SINGLE | SWT.BORDER ); - - SWTUtil.fillColumns(sequenceNameField, 3); - sequenceNameField.addModifyListener(new ModifyListener(){ - public void modifyText(ModifyEvent e) { - if (e.getSource() == null || !isUpdatingControls) { - - if ( idGeneratorCombo.getText().equals("sequence")) { //$NON-NLS-1$ - String sequenceName = sequenceNameField.getText(); - if ( sequenceName.toLowerCase().indexOf("$table") >= 0 || //$NON-NLS-1$ - sequenceName.toLowerCase().indexOf("$pk") >= 0 ) { //$NON-NLS-1$ - sequenceName = convertVarToLowerCase("$table", sequenceName); //$NON-NLS-1$ - sequenceName = convertVarToLowerCase("$pk", sequenceName); //$NON-NLS-1$ - } - if ( sequenceName.trim().length() != 0 ) { - mTable.setSequence( sequenceName ); - } else{ - mTable.setSequence( "" ); //$NON-NLS-1$ - } - } - } - } - - private String convertVarToLowerCase(String var, String sequenceName) { - int n = sequenceName.toLowerCase().indexOf( var ); - if( n==0 ) { - return var + sequenceName.substring( var.length()); - } else if( n >0 ) { - return sequenceName.substring(0,n) + var + sequenceName.substring( n + var.length()); - } - return sequenceName; - } - }); - - SWTUtil.newLabel(parent, "");//$NON-NLS-1$ - sequenceNameNoteLabel = new Label(parent, SWT.NONE); - String text =String.format( JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_sequenceNote, - ORMGenTable.TABLE_SEQ_PATTERN, ORMGenTable.PK_SEQ_PATTERN); - sequenceNameNoteLabel.setText( text ) ; - sequenceNameNoteLabel.setEnabled(false); - SWTUtil.fillColumns( sequenceNameNoteLabel, 3); - } - - private void idGenChanged() { - String scheme = idGeneratorCombo.getText(); - mTable.setIdGenerator(scheme); - - boolean isSequence = this.mTable.getCustomizer().getSequenceIdGenerators().contains(scheme); - if (!isSequence) { - sequenceNameField.setText(""); - sequenceNameField.setEnabled(false); - mTable.setSequence(null); - sequenceNameNoteLabel.setEnabled(false); - } else { - sequenceNameField.setEnabled(true); - Color NOTE_LABEL_COLOR = new Color( Display.getDefault(), 102,102,102); - sequenceNameNoteLabel.setForeground( NOTE_LABEL_COLOR ); - NOTE_LABEL_COLOR.dispose(); - sequenceNameNoteLabel.setEnabled(true); - if ( sequenceNameField.getText().length()==0 ) { - String newMessage = "Please specify a sequence name"; - this.wizardPage.setMessage(newMessage); - this.wizardPage.setPageComplete(true); - } else { - this.wizardPage.setErrorMessage(null); - this.wizardPage.setPageComplete(true); - } - } - } - - class EntityAccessFetchListener implements SelectionListener{ - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if (!isUpdatingControls) { - Button radioBtn = (Button)e.getSource(); - mTable.setAccess( radioBtn.getData().toString() ); - } - } - } - - private void createEntityAccessControls(Composite composite, int columns) { - SWTUtil.createLabel(composite, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_access ); - - Composite parent = new Composite( composite, SWT.NONE); - SWTUtil.fillColumns( parent , 3); - parent.setLayout(new RowLayout()); - - entityAccessField = new Button( parent, SWT.RADIO ); - entityAccessField.setText( "&Field" ); //$NON-NLS1$ - entityAccessField.setData( ORMGenTable.FIELD_ACCESS); - - entityAccessProperty = new Button( parent, SWT.RADIO ); - entityAccessProperty.setText( "&Property" );//$NON-NLS1$ - entityAccessProperty.setData( ORMGenTable.PROPERTY_ACCESS ); - - EntityAccessFetchListener entityAccessFetchListener = new EntityAccessFetchListener(); - entityAccessField.addSelectionListener( entityAccessFetchListener ); - entityAccessProperty.addSelectionListener( entityAccessFetchListener ); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TablesAndColumnsCustomizationWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TablesAndColumnsCustomizationWizardPage.java deleted file mode 100644 index 1dd211762d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TablesAndColumnsCustomizationWizardPage.java +++ /dev/null @@ -1,377 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; -import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.gen.internal.ORMGenColumn; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.gen.internal.ORMGenTable; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - -public class TablesAndColumnsCustomizationWizardPage extends NewTypeWizardPage { - - private JpaProject jpaProject; - - private TreeViewer tableColumnTreeViewer; - - private Composite detailPanel ; - private StackLayout detailPanelStatckLayout; - private Composite tableGenDetatilGroup; - private ColumnGenPanel columnGenPanel; - private Composite columnGenDetatilGroup; - private TableGenPanel tableGenPanel; - private ORMGenTable selectedTable; - - private ORMGenCustomizer customizer; - - protected final ResourceManager resourceManager; - - protected TablesAndColumnsCustomizationWizardPage(JpaProject jpaProject, ResourceManager resourceManager) { - super(true, "TablesAndColumnsCustomizationWizardPage"); //$NON-NLS-1$ - this.jpaProject = jpaProject; - this.resourceManager = resourceManager; - setTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_tablesAndColumnsPage_title ); - setMessage( JptUiEntityGenMessages.GenerateEntitiesWizard_tablesAndColumnsPage_desc); - } - - // -------- Initialization --------- - /** - * The wizard owning this page is responsible for calling this method with the - * current selection. The selection is used to initialize the fields of the wizard - * page. - * - * @param selection used to initialize the fields - */ - void init(IStructuredSelection selection) { - if ( jpaProject != null ) { - IJavaElement jelem = this.jpaProject.getJavaProject(); - initContainerPage(jelem); - initTypePage(jelem); - } - } - - public void createControl(Composite parent) { - initializeDialogUnits(parent); - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 1 ; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_CUSTOMIZE_INDIVIDUAL_ENTITIES); - - createTableAndColumnsListPanel(composite, 1); - - SWTUtil.createLabel( composite, 1, ""); //$NON-NLS-1$ - - SWTUtil.createSeparator(composite, 1); - - createGenerateDetailGroup(composite, 1); - - setControl(composite); - this.setPageComplete( true ); - } - - /** - * A panel with JFace TreeViewer showing tables and columns to be generated into JPA entities - * - * @param parent - * @param columns - */ - private void createTableAndColumnsListPanel(Composite parent, int columns) { - Label label = new Label(parent, columns ); - label.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_tablesAndColumnsPage_labelTableAndColumns ); - SWTUtil.fillColumns( label , columns); - - GridData data = new GridData(); - data.horizontalSpan = columns; - data.verticalAlignment = SWT.FILL; - data.horizontalAlignment = SWT.FILL; - data.grabExcessHorizontalSpace = true; - data.heightHint = 200; - data.grabExcessVerticalSpace = true; - - tableColumnTreeViewer = new TreeViewer(parent); - tableColumnTreeViewer.getTree().setLayoutData( data); - tableColumnTreeViewer.setContentProvider(new TableColumnTreeContentProvider()); - tableColumnTreeViewer.setLabelProvider(new TableColumnTreeLabelProvider()); - - tableColumnTreeViewer.addSelectionChangedListener( new ISelectionChangedListener(){ - public void selectionChanged(SelectionChangedEvent event) { - updateDetailPanel(event.getSelection()); - } - - }); - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if(visible){ - ORMGenCustomizer customizer = getCustomizer(); - //If user changed the connection or schema - if( this.customizer != customizer ){ - this.customizer = customizer; - tableColumnTreeViewer.setInput( customizer ); - }else{ - tableColumnTreeViewer.refresh(); - } - List<String> tableNames = this.customizer.getTableNames(); - - //Select the first table - ORMGenTable ormGenTable = this.customizer.getTable(tableNames.get(0)); - updateTabelGenDetail( ormGenTable ); - } - } - - - private void updateDetailPanel(ISelection selection) { - TreeSelection ts = (TreeSelection)selection; - Object selectedObject = ts.getFirstElement(); - if( selectedObject instanceof ORMGenTable ){ - updateTabelGenDetail( (ORMGenTable)selectedObject ); - }else if( selectedObject instanceof ORMGenColumn ){ - updateColumnGenDetail( (ORMGenColumn)selectedObject ); - } - } - - private void updateColumnGenDetail(ORMGenColumn column) { - if(columnGenDetatilGroup==null){ - columnGenDetatilGroup = new Composite(detailPanel, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 4; - columnGenDetatilGroup.setLayout(gridLayout); - this.columnGenPanel = new ColumnGenPanel(columnGenDetatilGroup, 4, getCustomizer() , this ); - } - columnGenPanel.setColumn(column); - this.detailPanelStatckLayout.topControl = columnGenDetatilGroup; - this.detailPanel.layout(); - detailPanel.getParent().layout(); - } - - private void updateTabelGenDetail(ORMGenTable table) { - this.selectedTable = table; - if(tableGenDetatilGroup==null){ - tableGenDetatilGroup = new Composite(detailPanel, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 4; - tableGenDetatilGroup.setLayout(gridLayout); - - this.tableGenPanel = new TableGenPanel(tableGenDetatilGroup, 4 , false, this ); - createDomainJavaClassesPropertiesGroup(tableGenDetatilGroup, 4 ); - } - tableGenPanel.setORMGenTable(table); - - this.detailPanelStatckLayout.topControl = tableGenDetatilGroup; - this.detailPanel.layout(); - - String baseClass = table.getExtends(); - if( baseClass!= null ) - setSuperClass(baseClass, true); - - setSuperInterfaces( table.getImplements(), true); - - detailPanel.getParent().layout(); - } - - protected void createDomainJavaClassesPropertiesGroup(Composite composite, int columns) { - Group parent = new Group( composite, SWT.NONE); - parent.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_defaultTablePage_domainJavaClass ); - parent.setLayout(new GridLayout(columns, false)); - SWTUtil.fillColumns( parent, columns); - - createSuperClassControls(parent, columns); - createSuperInterfacesControls(parent, columns); - - //Resize supper class text width to fill the parent group. - //Have to do it indirectly since fSuperClassDialogField is private in super class. - Control[] controls = parent.getChildren(); - if( controls.length>1 && controls[1] instanceof Text ){ - Text text = (Text)(parent.getChildren()[1]); - LayoutUtil.setWidthHint(text, getMaxFieldWidth()); - LayoutUtil.setHorizontalGrabbing(text); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.NewTypeWizardPage#superClassChanged() - */ - @Override - protected IStatus superClassChanged() { - IStatus status = super.superClassChanged(); - String baseClass = getSuperClass(); - if(baseClass!=null && this.selectedTable!=null ){ - String oldBaseClass = this.selectedTable.getExtends(); - if( !oldBaseClass.equals(baseClass )) - this.selectedTable.setExtends(baseClass); - } - return status; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.NewTypeWizardPage#addSuperInterface(java.lang.String) - */ - @Override - @SuppressWarnings("unchecked") - public boolean addSuperInterface(String superInterface) { - super.addSuperInterface(superInterface); - List interfaces = getSuperInterfaces(); - if(this.selectedTable!=null) - this.selectedTable.setImplements(interfaces); - return true; - } - - @Override - protected void handleFieldChanged(String fieldName) { - super.handleFieldChanged(fieldName); - if( this.fSuperClassStatus.matches(IStatus.ERROR)){ - updateStatus(fSuperClassStatus); - }else{ - setMessage("", IMessageProvider.NONE); - setErrorMessage(null); - } - - } - - private ORMGenCustomizer getCustomizer(){ - GenerateEntitiesFromSchemaWizard wizard = (GenerateEntitiesFromSchemaWizard) this.getWizard(); - return wizard.getCustomizer(); - } - /** - * Content provider, and label provider for the DB Table/Column TreeViewer - * - */ - class TableColumnTreeContentProvider implements ITreeContentProvider { - public Object[] getElements(Object inputElement) { - if( inputElement instanceof ORMGenCustomizer ){ - ORMGenCustomizer input = (ORMGenCustomizer )inputElement; - List<String> tableNameList = input.getGenTableNames(); - List<ORMGenTable> ret = new ArrayList<ORMGenTable>(); - for(String t : tableNameList){ - ORMGenTable ormGenTable = getCustomizer().getTable( t ); - ret.add( ormGenTable ); - } - return ret.toArray(); - } - return new Object[]{}; - } - public Object[] getChildren(Object parentElement) { - if( parentElement instanceof ORMGenTable ){ - ORMGenTable table = (ORMGenTable) parentElement; - List<ORMGenColumn> columns = table.getColumns(); - List<ORMGenColumn> ret = new ArrayList<ORMGenColumn>(); - for( ORMGenColumn col : columns){ - if( col.isForeignKey() ) - continue; - if( col.isPrimaryKey() ){ - ret.add(0,col ); - }else{ - ret.add(col); - } - } - return ret.toArray(); - } - return new Object[]{}; - } - public Object getParent(Object element) { - if( element instanceof ORMGenColumn){ - return null; - } - return null; - } - public boolean hasChildren(Object element) { - return( element instanceof ORMGenTable ); - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} - public void dispose() {} - } - - class TableColumnTreeLabelProvider extends LabelProvider{ - - @Override - public Image getImage(Object element) { - if( element instanceof ORMGenTable ){ - return ImageRepository.getTableImage(resourceManager); - }else if( element instanceof ORMGenColumn ){ - ORMGenColumn col = ( ORMGenColumn)element; - return col.isPrimaryKey() ? - ImageRepository.getKeyColumnImage(resourceManager) : - ImageRepository.getColumnImage(resourceManager); - } - return null; - } - - - @Override - public String getText(Object element) { - if( element instanceof ORMGenTable ){ - return ((ORMGenTable)element).getName(); - }else if( element instanceof ORMGenColumn ){ - return ((ORMGenColumn)element).getName(); - } - return super.getText(element); - } - } - - private void createGenerateDetailGroup(Composite parent, int columns) { - detailPanel = new Composite(parent, SWT.NONE); - SWTUtil.fillColumns( detailPanel, columns); - - detailPanelStatckLayout = new StackLayout(); - detailPanel.setLayout(detailPanelStatckLayout); - - Composite emptyPanel = new Composite(detailPanel, SWT.NONE); - emptyPanel.setLayoutData(new GridData()); - - detailPanelStatckLayout.topControl = emptyPanel; - detailPanel.layout(); - } - - @Override - public final void performHelp() - { - this.getHelpSystem().displayHelp( GenerateEntitiesFromSchemaWizard.HELP_CONTEXT_ID ); - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TablesSelectorWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TablesSelectorWizardPage.java deleted file mode 100644 index a4613f3e00..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/gen/TablesSelectorWizardPage.java +++ /dev/null @@ -1,557 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.jpa.ui.internal.wizards.gen; - -import java.lang.reflect.InvocationTargetException; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ResourceManager; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.util.TableLayoutComposite; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.JptJpaDbPlugin; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.jpt.jpa.gen.internal.ORMGenCustomizer; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.ImageRepository; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - -class TablesSelectorWizardPage extends WizardPage{ - - private static final int TABLE_COLUMN_INDEX = 0; - private JpaProject jpaProject; - private Schema schema = null; - private ORMGenCustomizer customizer = null; - private boolean updatePersistenceXml = true; - - private DatabaseGroup databaseGroup; - private CheckboxTableViewer tableTable; - private Button updatePersistenceXmlCheckBox; - - protected final ResourceManager resourceManager; - - TablesSelectorWizardPage(JpaProject jpaProject, ResourceManager resourceManager) { - super("TablesSelectorWizardPage"); //$NON-NLS-1$ - this.jpaProject = jpaProject; - this.resourceManager = resourceManager; - this.schema = jpaProject.getDefaultDbSchema(); - setTitle(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_selectTable ); - setMessage(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_chooseEntityTable ); - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - doStatusUpdate(); - } - - // -------- Provide access to wrapped DTP connection related classes --------- - ConnectionProfile getProjectConnectionProfile() { - String profileName = this.jpaProject.getDataSource().getConnectionProfileName(); - return this.connectionProfileNamed(profileName); - } - - ConnectionProfile connectionProfileNamed(String profileName) { - return JptJpaDbPlugin.getConnectionProfileFactory().buildConnectionProfile(profileName); - } - - Schema getSchema(){ - return this.schema; - } - - void setSchema(Schema s){ - this.schema = s; - } - - private Collection<Table> possibleTables() { - Schema schema = this.getSchema(); - if (schema != null && schema.getName() != null) { - return CollectionTools.collection(schema.getTables()); - } - return Collections.<Table> emptyList(); - } - - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - int nColumns= 3; - GridLayout layout = new GridLayout(); - layout.numColumns = nColumns; - composite.setLayout(layout); - this.getHelpSystem().setHelp(composite, JpaHelpContextIds.GENERATE_ENTITIES_WIZARD_SELECT_TABLES); - - this.databaseGroup = createDatabaseGroup(composite, 400); - - createTablesSelectionControl(composite, nColumns); - - - this.updatePersistenceXmlCheckBox = new Button(composite, SWT.CHECK); - this.updatePersistenceXmlCheckBox.setText(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_updatePersistenceXml ); - this.updatePersistenceXmlCheckBox.setSelection(updatePersistenceXml()); - this.updatePersistenceXmlCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - setShouldUpdatePersistenceXml(updatePersistenceXmlCheckBox.getSelection()); - } - - }); - fillColumns( this.updatePersistenceXmlCheckBox, 3); - - - //Filler column - new Label( composite, SWT.NONE); - //Restore default button - final Button restoreBtn = new Button(composite, SWT.PUSH ); - restoreBtn.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_Restore_Defaults ); - restoreBtn.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - if( customizer!=null && customizer.getFile()!=null ){ - if( customizer.getFile().exists() ){ - customizer.getFile().delete(); - } - deselectAllTables(); - restoreUpdatePersistenceXmlDefault(); - } - } - - }); - GridData gridData = new GridData(); - gridData.horizontalAlignment = SWT.END; - restoreBtn.setLayoutData(gridData); - - this.updateSelectionState(databaseGroup.getSelectedSchema()); - this.getHelpSystem().setHelp(this.tableTable.getControl(), JpaHelpContextIds.DIALOG_GENERATE_ENTITIES_TABLES); - this.setControl(composite); - - this.setPageComplete(true); - } - - private void restoreUpdatePersistenceXmlDefault(){ - updatePersistenceXmlCheckBox.setSelection(true); - setShouldUpdatePersistenceXml(true); - } - - @Override - public void dispose() { - if (this.databaseGroup != null) - this.databaseGroup.dispose(); - super.dispose(); - } - - @Override - public IWizardPage getPreviousPage() { - IWizardPage prevPage = super.getPreviousPage(); - if (prevPage instanceof PromptJPAProjectWizardPage) - //Prevent going back to the PromptJPAProjectWizardPage - //if JPA project already selected - return prevPage.getPreviousPage(); - else - return prevPage; - } - - private DatabaseGroup createDatabaseGroup(Composite parent, int widthHint) { - DatabaseGroup dbGroup = new DatabaseGroup(this.getContainer(), jpaProject, parent, resourceManager, widthHint); - /** - * listen for when the Database Connection changes its selected schema - * so we can keep the page in synch - */ - class DatabasePageListener implements DatabaseGroup.Listener { - public void selectedConnectionProfileChanged(ConnectionProfile connectionProfile) { - jpaProject.getDataSource().setConnectionProfileName(connectionProfile.getName()); - } - @SuppressWarnings("unchecked") - public void selectedSchemaChanged(Schema schema) { - if (schema==null) { - updateTablesListViewer(Collections.EMPTY_LIST ); - } else { - // store the *identifier* in the JPA project, since it gets put in Java annotations - jpaProject.setUserOverrideDefaultSchema(schema.getIdentifier()); - setSchema( schema ); - updateSelectionState(schema); - } - doStatusUpdate(); - } - } - dbGroup.addListener(new DatabasePageListener()); - dbGroup.init(); - return dbGroup; - } - - private boolean updatePersistenceXml() { - return this.updatePersistenceXml; - } - - private void setShouldUpdatePersistenceXml(boolean updatePersistenceXml){ - this.updatePersistenceXml = updatePersistenceXml; - doStatusUpdate(); - } - - private void selectAllTables(){ - this.tableTable.setAllChecked(true); - doStatusUpdate(); - } - - private void deselectAllTables(){ - this.tableTable.setAllChecked(false); - doStatusUpdate(); - } - - private void initTablesSelectionControl(Collection<Table> possibleTables) { - this.tableTable.setInput(possibleTables); - } - - private void createTablesSelectionControl(Composite parent, int columns) { - Label tableLabel = new Label(parent, SWT.NONE); - GridData gd= new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.verticalAlignment = GridData.BEGINNING; - tableLabel.setLayoutData( gd ); - tableLabel.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_tables ); - - TableLayoutComposite layout= new TableLayoutComposite(parent, SWT.NONE); - addColumnLayoutData(layout); - - final org.eclipse.swt.widgets.Table table = new org.eclipse.swt.widgets.Table(layout, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.CHECK); - - TableColumn tableNameColumn = new TableColumn(table, SWT.NONE, TABLE_COLUMN_INDEX); - tableNameColumn.setText(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_tableColumn ); - tableNameColumn.setResizable(true); - - gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= SWTUtil.getTableHeightHint(table, 20); - gd.widthHint = 250; - gd.grabExcessHorizontalSpace = true; - gd.grabExcessVerticalSpace = true ; - layout.setLayoutData(gd); - Color backgroundColor = new Color( Display.getDefault(), 255, 0,0); - layout.setBackground(backgroundColor); - backgroundColor.dispose(); - - this.tableTable = new CheckboxTableViewer(table); - this.tableTable.setUseHashlookup(true); - this.tableTable.setLabelProvider(this.buildTableTableLabelProvider()); - this.tableTable.setContentProvider(this.buildTableTableContentProvider()); - this.tableTable.setSorter(new ViewerSorter() { - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - return ((Table) e1).getName().compareTo(((Table) e2).getName()); - } - }); - - this.tableTable.addPostSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - handleTablesListSelectionChanged(event); - } - }); - - table.addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if (e.keyCode == SWT.F2 && e.stateMask == SWT.NONE) { - editEntityNameIfPossible(); - e.doit= false; - } - } - }); - - createButtonComposite(parent); - initTablesSelectionControl(possibleTables()); - } - - private void createButtonComposite(Composite parent){ - - Composite buttonComposite = new Composite(parent, SWT.NULL); - GridLayout buttonLayout = new GridLayout(1, false); - buttonLayout.marginHeight = 0; - buttonLayout.marginWidth = 0; - - buttonComposite.setLayout(buttonLayout); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.BEGINNING; - buttonComposite.setLayoutData(data); - - Button selectAllButton = new Button(buttonComposite, SWT.PUSH); - selectAllButton.setToolTipText(JptUiMessages.General_selectAll); - selectAllButton.setImage( ImageRepository.getSelectAllButtonImage(this.resourceManager) ); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - selectAllButton.setLayoutData(gridData); - selectAllButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - selectAllTables(); - } - }); - - Button deselectAllButton = new Button(buttonComposite, SWT.PUSH); - deselectAllButton.setToolTipText(JptUiMessages.General_deselectAll); - deselectAllButton.setImage( ImageRepository.getDeselectAllButtonImage(this.resourceManager) ); - gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - deselectAllButton.setLayoutData(gridData); - deselectAllButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - deselectAllTables(); - } - }); - } - - - private void addColumnLayoutData(TableLayoutComposite layout) { - layout.addColumnData(new ColumnWeightData(50, true)); - } - - void editEntityNameIfPossible(){ - Object[] selected = ((IStructuredSelection) this.tableTable.getSelection()).toArray(); - if (selected.length != 1) { - return; - } - } - - void handleTablesListSelectionChanged(SelectionChangedEvent event) { - doStatusUpdate(); - } - - private IBaseLabelProvider buildTableTableLabelProvider() { - return new TableTableLabelProvider(); - } - - private IContentProvider buildTableTableContentProvider() { - return new TableTableContentProvider(); - } - - public Schema getDefaultSchema() { - return this.jpaProject.getDefaultDbSchema() ; - } - - Collection<Table> getSelectedTables() { - ArrayList<Table> selectedTables = new ArrayList<Table>(); - for (Object selectedTable : this.tableTable.getCheckedElements()) - selectedTables.add((Table) selectedTable); - return selectedTables; - } - - private boolean hasTablesSelected() { - return (this.tableTable != null) ? (this.getSelectedTables().size() > 0) : false; - } - - void updateTablesListViewer(Collection<Table> possibleTables) { - if (this.tableTable != null) { - this.initTablesSelectionControl(possibleTables); - } - } - - /** - * Update the status line and the OK button according to the given status - */ - protected void doStatusUpdate() { - if ( ! this.hasTablesSelected()) { - this.setPageComplete(false); - }else{ - setPageComplete(true); - try{ - getContainer().run(false, false, new IRunnableWithProgress(){ - public void run( final IProgressMonitor monitor ) - throws InvocationTargetException, InterruptedException - { - monitor.beginTask("Updating", 10); - - Collection<Table> ret = getSelectedTables(); - ArrayList<String> tableNames = new ArrayList<String>(); - for( Table t : ret ){ - tableNames.add(t.getName()); - } - Schema schema = getSchema(); - if( schema == null ){ - return ; - } - customizer.setSchema(schema); - customizer.setTableNames(tableNames); - customizer.setUpdatePersistenceXml(updatePersistenceXml); - monitor.done(); - } - }); - } catch (Exception e) { - JptJpaUiPlugin.log(e); - } - - } - } - - // ********** inner classes ********** - private class TableTableLabelProvider extends LabelProvider implements ITableLabelProvider { - - TableTableLabelProvider() { - super(); - } - - @Override - public String getText(Object element) { - return ((Table) element).getName(); - } - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - if (element == null) { - return null; - } - switch (columnIndex) { - case TABLE_COLUMN_INDEX: - return ((Table) element).getName(); - - } - throw new IllegalArgumentException("invalid column index: " + columnIndex);// $NON-NLS-1$ - } - - } - - - private class TableTableContentProvider implements IStructuredContentProvider { - - TableTableContentProvider() { - super(); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } - - public void dispose() {} - - public Object[] getElements(Object inputElement) { - return ((Collection<?>) inputElement).toArray(); - } - - } - - private void updateSelectionState(final Schema schema) { - if(schema ==null) - return; - this.jpaProject.setUserOverrideDefaultSchema( schema.getIdentifier()); - - updateTablesListViewer(CollectionTools.collection(schema.getTables())); - - //Create the ORMGenCustomizer - GenerateEntitiesFromSchemaWizard wizard = (GenerateEntitiesFromSchemaWizard) getWizard(); - customizer = wizard.createORMGenCustomizer( schema ); - - if( this.tableTable!=null && this.updatePersistenceXmlCheckBox!=null && customizer != null ){ - restoreWizardState(); - } - doStatusUpdate(); - - } - - private boolean restoreWizardState(){ - boolean pageComplete = false; - this.updatePersistenceXmlCheckBox.setSelection(this.customizer.updatePersistenceXml()); - List<String> preSelectedTableNames = this.customizer.getTableNames(); - if(preSelectedTableNames!=null && preSelectedTableNames.size()>0) { - Set<String> set = new HashSet<String>(); - for(String s : preSelectedTableNames ){ - set.add(s); - } - TableItem[] items = this.tableTable.getTable().getItems(); - for (int i = 0; i < items.length; ++i) { - TableItem item = items[i]; - org.eclipse.jpt.jpa.db.Table element = (org.eclipse.jpt.jpa.db.Table)item.getData(); - if (element != null) { - boolean check = set.contains(element.getName()); - // only set if different, to avoid flicker - if (item.getChecked() != check) { - item.setChecked(check); - pageComplete = true; - } - } - } - } - return pageComplete; - } - - - /** - * Set the layoutData of the input control to occupy specified number of columns - * @param c - * @param columns - */ - private void fillColumns(Control c, int columns){ - GridData layoutData = new GridData(); - layoutData.horizontalSpan = columns; - layoutData.verticalAlignment = SWT.FILL; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = false; - c.setLayoutData(layoutData); - return ; - } - - @Override - public final void performHelp() - { - this.getHelpSystem().displayHelp( GenerateEntitiesFromSchemaWizard.HELP_CONTEXT_ID ); - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java deleted file mode 100644 index 4803e1d5ec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.orm; - -import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class MappingFileNewFileWizardPage - extends WizardNewFileCreationPage { - - protected IDataModel dataModel; - - - public MappingFileNewFileWizardPage( - String pageName, IStructuredSelection selection, IDataModel dataModel, - String title, String description) { - - super(pageName, selection); - init(dataModel); - setTitle(title); - setDescription(description); - } - - - protected void init(IDataModel dataModel) { - this.dataModel = dataModel; - IPath containerPath = (IPath) this.dataModel.getProperty(CONTAINER_PATH); - if (containerPath != null) { - setContainerFullPath(containerPath); - } - String fileName = (String) this.dataModel.getProperty(FILE_NAME); - if (fileName != null) { - setFileName(fileName); - } - } - - @Override - protected boolean validatePage() { - this.dataModel.setProperty(CONTAINER_PATH, getContainerFullPath()); - this.dataModel.setProperty(FILE_NAME, getFileName()); - - boolean valid = super.validatePage(); - if (! valid) { - return valid; - } - - IStatus validationStatus = this.dataModel.validateProperty(CONTAINER_PATH); - if (validationStatus.isOK()) { - validationStatus = this.dataModel.validateProperty(FILE_NAME); - } - if (validationStatus.isOK()) { - setErrorMessage(null); - return true; - } - else if (validationStatus.getSeverity() == IStatus.WARNING) { - setErrorMessage(null); - setMessage(validationStatus.getMessage(), IStatus.WARNING); - return true; - } - else { - setErrorMessage(validationStatus.getMessage()); - return false; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java deleted file mode 100644 index d6484a7f06..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.orm; - -import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*; -import static org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProperties.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Label; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; - -public class MappingFileOptionsWizardPage - extends DataModelWizardPage { - - private Label accessLabel; - - private Combo accessCombo; - - private Button addToPersistenceUnitButton; - - private Label persistenceUnitLabel; - - private Combo persistenceUnitCombo; - - - public MappingFileOptionsWizardPage( - String pageName, IDataModel dataModel, - String title, String description) { - - super(dataModel, pageName); - setTitle(title); - setDescription(description); - setPageComplete(false); - } - - - @Override - protected String[] getValidationPropertyNames() { - return new String[] { - CONTAINER_PATH, - FILE_NAME, - DEFAULT_ACCESS, - ADD_TO_PERSISTENCE_UNIT, - PERSISTENCE_UNIT - }; - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - composite.setLayout(layout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - - this.accessLabel = new Label(composite, SWT.NONE); - this.accessLabel.setText(JptUiMessages.MappingFileWizardPage_accessLabel); - data = new GridData(); - this.accessLabel.setLayoutData(data); - - this.accessCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 1; - data.grabExcessHorizontalSpace = true; - this.accessCombo.setLayoutData(data); - this.synchHelper.synchCombo(this.accessCombo, DEFAULT_ACCESS, null); - new Label(composite, SWT.NONE); - - this.addToPersistenceUnitButton = new Button(composite, SWT.CHECK | SWT.BEGINNING); - this.addToPersistenceUnitButton.setText(JptUiMessages.MappingFileWizardPage_addToPersistenceUnitButton); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - data.verticalIndent = 10; - this.addToPersistenceUnitButton.setLayoutData(data); - this.synchHelper.synchCheckbox(this.addToPersistenceUnitButton, ADD_TO_PERSISTENCE_UNIT, null); - - this.persistenceUnitLabel = new Label(composite, SWT.NONE); - this.persistenceUnitLabel.setText(JptUiMessages.MappingFileWizardPage_persistenceUnitLabel); - data = new GridData(); - data.horizontalIndent = 10; - this.persistenceUnitLabel.setLayoutData(data); - this.persistenceUnitLabel.setEnabled(false); - this.addToPersistenceUnitButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - persistenceUnitLabel.setEnabled(addToPersistenceUnitButton.getSelection()); - } - public void widgetDefaultSelected(SelectionEvent e) {/*not called*/} - }); - - this.persistenceUnitCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 1; - data.grabExcessHorizontalSpace = true; - this.persistenceUnitCombo.setLayoutData(data); - this.synchHelper.synchCombo(this.persistenceUnitCombo, PERSISTENCE_UNIT, null); - - new Label(composite, SWT.NONE); - -// classText.setFocus(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID()); - Dialog.applyDialogFont(parent); - return composite; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java deleted file mode 100644 index b1b70cea79..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java +++ /dev/null @@ -1,347 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - *******************************************************************************/ -package org.eclipse.jpt.jpa.ui.internal.wizards.orm; - -import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*; -import static org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProperties.*; -import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.core.internal.utility.PlatformTools; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.datamodel.IDataModelPausibleOperation; -import org.eclipse.wst.common.frameworks.internal.dialog.ui.WarningDialog; -import org.eclipse.wst.common.frameworks.internal.ui.ErrorDialog; -import org.eclipse.wst.common.frameworks.internal.ui.WTPCommonUIResourceHandler; - -public class MappingFileWizard extends Wizard - implements INewWizard -{ - protected IDataModel dataModel; - - protected IStructuredSelection initialSelection; - - protected IStructuredSelection mungedSelection; - - private IWizardPage firstPage; - - private IWizardPage secondPage; - - - public MappingFileWizard() { - this(null); - } - - public MappingFileWizard(IDataModel dataModel) { - super(); - this.dataModel = dataModel; - setWindowTitle(JptUiMessages.MappingFileWizard_title); - setDefaultPageImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.JPA_FILE_WIZ_BANNER)); - } - - - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.initialSelection = selection; - this.mungedSelection = selection; - - if (selection == null || selection.isEmpty()) { - return; - } - - Object firstSelection = selection.getFirstElement(); - - PersistenceUnit pUnit = extractPersistenceUnit(firstSelection); - IContainer container = extractContainer(pUnit, firstSelection); - - if (container != null) { - this.mungedSelection = new StructuredSelection(container); - } - - if (pUnit != null) { - getDataModel().setBooleanProperty(ADD_TO_PERSISTENCE_UNIT, true); - getDataModel().setStringProperty(PERSISTENCE_UNIT, pUnit.getName()); - } - } - - private PersistenceUnit extractPersistenceUnit(Object selection) { - if (selection instanceof JpaContextNode) { - // may be null if node is above level of persistence unit, but in those cases - // null is the expected result - try { - return ((JpaContextNode) selection).getPersistenceUnit(); - } - catch (Exception e) { /* do nothing, just continue */ } - } - - if (selection instanceof IAdaptable) { - JpaContextNode node = (JpaContextNode) ((IAdaptable) selection).getAdapter(JpaContextNode.class); - if (node != null) { - return node.getPersistenceUnit(); - } - } - return null; - } - - private IContainer extractContainer(PersistenceUnit pUnit, Object selection) { - if (pUnit != null) { - return pUnit.getResource().getParent(); - } - if (selection instanceof IProject) { - return getDefaultContainer((IProject) selection); - } - if (selection instanceof IContainer) { - return (IContainer) selection; - } - if (selection instanceof JpaContextNode) { - return getDefaultContainer(((JpaContextNode) selection).getJpaProject().getProject()); - } - - if (selection instanceof IAdaptable) { - IResource resource = (IResource) ((IAdaptable) selection).getAdapter(IResource.class); - if (resource != null) { - if (resource instanceof IProject) { - return getDefaultContainer((IProject) resource); - } - else if (resource instanceof IContainer) { - return (IContainer) resource; - } - } - JpaContextNode node = (JpaContextNode) ((IAdaptable) selection).getAdapter(JpaContextNode.class); - if (node != null) { - return getDefaultContainer(node.getJpaProject().getProject()); - } - } - return null; - } - - private IContainer getDefaultContainer(IProject project) { - if (JpaFacet.isInstalled(project)) { - return JptCommonCorePlugin.getResourceLocator(project).getDefaultResourceLocation(project); - } - return project; - } - - @Override - public void addPages() { - super.addPages(); - this.firstPage = buildMappingFileNewFileWizardPage(); - this.secondPage = buildMappingFileOptionsWizardPage(); - addPage(this.firstPage); - addPage(this.secondPage); - } - - protected MappingFileNewFileWizardPage buildMappingFileNewFileWizardPage() { - return new MappingFileNewFileWizardPage( - "Page_1", this.mungedSelection, getDataModel(), - JptUiMessages.MappingFileWizardPage_newFile_title, - JptUiMessages.MappingFileWizardPage_newFile_desc); - } - - protected MappingFileOptionsWizardPage buildMappingFileOptionsWizardPage() { - return new MappingFileOptionsWizardPage( - "Page_2", getDataModel(), - JptUiMessages.MappingFileWizardPage_options_title, - JptUiMessages.MappingFileWizardPage_options_desc); - } - - @Override - public boolean canFinish() { - // override so that visit to second page is not necessary - return this.firstPage.isPageComplete() && getDataModel().isValid(); - } - - public IDataModel getDataModel() { - if (this.dataModel == null) { - this.dataModel = DataModelFactory.createDataModel(getDefaultProvider()); - } - return this.dataModel; - } - - protected IDataModelProvider getDefaultProvider() { - return new OrmFileCreationDataModelProvider(); - } - - protected IDataModelPausibleOperation getOperation() { - return (IDataModelPausibleOperation) getDataModel().getDefaultOperation(); - } - - @Override - public final boolean performFinish() { - try { - final IStatus st = runOperations(); - - if (st.getSeverity() == IStatus.ERROR) { - JptJpaUiPlugin.log(st); - Throwable t = st.getException() == null ? new CoreException(st) : st.getException(); - ErrorDialog.openError( - getShell(), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}), - t, 0, false); - } - else if(st.getSeverity() == IStatus.WARNING){ - WarningDialog.openWarning( - getShell(), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_2, new Object[]{getWindowTitle()}), - st.getMessage(), - st, IStatus.WARNING); - } - - postPerformFinish(); - } - catch (Exception e) { - JptJpaUiPlugin.log(e); - ErrorDialog.openError( - getShell(), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}), - e, 0, false); - } - return true; - } - - private IStatus runOperations() { - - class CatchThrowableRunnableWithProgress - implements IRunnableWithProgress { - - public IStatus status = null; - public Throwable caught = null; - - public void run(IProgressMonitor pm) { - try { - status = getOperation().execute(pm, null); - } - catch (Throwable e) { - caught = e; - } - } - } - - CatchThrowableRunnableWithProgress runnable = new CatchThrowableRunnableWithProgress(); - - try { - getContainer().run(true, false, runnable); - } - catch (Throwable e) { - runnable.caught = e; - } - - if (runnable.caught == null) { - return runnable.status; - } - else { - JptJpaUiPlugin.log(runnable.caught); - ErrorDialog.openError( - getShell(), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}), - WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}), - runnable.caught, 0, false); - return new Status(IStatus.ERROR, "id", 0, runnable.caught.getMessage(), runnable.caught); //$NON-NLS-1$ - } - } - - protected void postPerformFinish() - throws InvocationTargetException { - - try { - IPath containerPath = (IPath) getDataModel().getProperty(CONTAINER_PATH); - String fileName = getDataModel().getStringProperty(FILE_NAME); - IContainer container = PlatformTools.getContainer(containerPath); - IFile file = container.getFile(new Path(fileName)); - openEditor(file); - } - catch (Exception cantOpen) { - throw new InvocationTargetException(cantOpen); - } - } - - private void openEditor(final IFile file) { - if (file != null) { - getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - try { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IDE.openEditor(page, file, true); - } - catch (PartInitException e) { - JptJpaUiPlugin.log(e); - } - } - }); - } - } - - @Override - public void dispose() { - super.dispose(); - getDataModel().dispose(); - } - - public static IPath createNewMappingFile(IStructuredSelection selection, String xmlFileName) { - MappingFileWizard wizard = new MappingFileWizard(DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider())); - wizard.getDataModel().setProperty(FILE_NAME, xmlFileName); - wizard.init(PlatformUI.getWorkbench(), selection); - WizardDialog dialog = new WizardDialog(getCurrentShell(), wizard); - dialog.create(); - if (dialog.open() == Window.OK) { - IPath containerPath = (IPath) wizard.getDataModel().getProperty(CONTAINER_PATH); - String fileName = wizard.getDataModel().getStringProperty(FILE_NAME); - IContainer container = PlatformTools.getContainer(containerPath); - IPath filePath = container.getFullPath().append(fileName); - IProject project = container.getProject(); - IPath runtimePath = JptCommonCorePlugin.getResourceLocator(project).getRuntimePath(project, filePath); - - return runtimePath; - } - return null; - } - - private static Shell getCurrentShell() { - return Display.getCurrent().getActiveShell(); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/AddToEarComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/AddToEarComposite.java deleted file mode 100644 index 3b4f1efa4e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/AddToEarComposite.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards.proj; - -import static org.eclipse.jpt.jpa.ui.internal.wizards.proj.model.JpaProjectCreationDataModelProperties.*; -import static org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FACET_RUNTIME; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -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.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public class AddToEarComposite { - - private final Button addToEar; - private final Combo combo; - private final Button newButton; - private final Label label; - - private final IDataModel model; - private DataModelSynchHelper synchhelper; - - public AddToEarComposite(IDataModel model, Composite parent) { - this.model = model; - this.synchhelper = new DataModelSynchHelper(model); - - Group group = new Group(parent, SWT.NONE); - group.setLayoutData(gdhfill()); - group.setLayout(new GridLayout(3, false)); - group.setText(JptUiMessages.AddToEarComposite_earMemberShip); - - this.addToEar = new Button(group, SWT.CHECK); - this.addToEar.setText(JptUiMessages.AddToEarComposite_addToEarLabel); - GridDataFactory.defaultsFor(this.addToEar).span(3, 1).applyTo(this.addToEar); - this.synchhelper.synchCheckbox(addToEar, ADD_TO_EAR, null); - - this.label = new Label(group, SWT.NULL); - this.label.setText(JptUiMessages.AddToEarComposite_earProjectLabel); - this.combo = new Combo(group, SWT.NONE); - this.combo.setLayoutData(gdhfill()); - - this.newButton = new Button(group, SWT.PUSH); - this.newButton.setText(JptUiMessages.AddToEarComposite_newButtonLabel); - GridDataFactory.defaultsFor(this.newButton).applyTo(this.newButton); - - this.newButton.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - handleAddButton(); - } - }); - - this.synchhelper.synchCombo(combo, EAR_PROJECT_NAME, new Control[]{label, newButton}); - Dialog.applyDialogFont(parent); - } - - private void handleAddButton() { - EarProjectWizard wizard = new EarProjectWizard(); - - WizardDialog dialog = new WizardDialog(newButton.getShell(), wizard); - - IRuntime runtime = (IRuntime) this.model.getProperty(FACET_RUNTIME); - wizard.setRuntimeInDataModel(runtime); - - if (dialog.open() != Window.CANCEL) { - this.model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - String earproj = wizard.getProjectName(); - this.model.setProperty(EAR_PROJECT_NAME, earproj); - } - } - - private static GridData gdhfill() { - return new GridData(GridData.FILL_HORIZONTAL); - } - - public static final GridData gdhspan(GridData gd, int span) { - gd.horizontalSpan = span; - return gd; - } - - public void dispose() { - if (this.synchhelper != null){ - this.synchhelper.dispose(); - this.synchhelper = null; - } - } - - public String getComboText(){ - return this.combo.getText(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/JpaProjectWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/JpaProjectWizard.java deleted file mode 100644 index c467795ea4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/JpaProjectWizard.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards.proj; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; -import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.wizards.proj.model.JpaProjectCreationDataModelProvider; -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 JpaProjectWizard - extends NewProjectDataModelFacetWizard { - - public JpaProjectWizard() { - super(); - setWindowTitle(JptUiMessages.JpaProjectWizard_title); - } - - public JpaProjectWizard(IDataModel dataModel) { - super(dataModel); - setWindowTitle(JptUiMessages.JpaProjectWizard_title); - } - - - @Override - protected ImageDescriptor getDefaultPageImageDescriptor() { - return JptJpaUiPlugin.getImageDescriptor(JptUiIcons.JPA_WIZ_BANNER); - } - - @Override - protected IWizardPage createFirstPage() { - return new JpaProjectWizardFirstPage(model, "first.page"); //$NON-NLS-1$ - } - - @Override - protected IDataModel createDataModel() { - return DataModelFactory.createDataModel(new JpaProjectCreationDataModelProvider()); - } - - @Override - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("jpt.jpa.template"); - } - - @Override - protected String getFinalPerspectiveID() { - return "org.eclipse.jpt.ui.jpaPerspective"; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/JpaProjectWizardFirstPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/JpaProjectWizardFirstPage.java deleted file mode 100644 index 33b11a0b74..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/JpaProjectWizardFirstPage.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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.jpa.ui.internal.wizards.proj; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.internal.facet.FacetTools; -import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; -import org.eclipse.jpt.jpa.ui.internal.wizards.proj.model.JpaProjectCreationDataModelProperties; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -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.web.ui.internal.wizards.DataModelFacetCreationWizardPage; - -public class JpaProjectWizardFirstPage - extends DataModelFacetCreationWizardPage { - - private AddToEarComposite addToEarComposite; - - public JpaProjectWizardFirstPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(JptUiMessages.NewJpaProjectWizard_firstPage_title); - setDescription(JptUiMessages.NewJpaProjectWizard_firstPage_description); - setInfopopID(JpaHelpContextIds.NEW_JPA_PROJECT); - } - - - @Override - protected Composite createTopLevelComposite(Composite parent) { - final Composite top = super.createTopLevelComposite(parent); - createEarComposite(top); - createWorkingSetGroupPanel(top, new String[] { RESOURCE_WORKING_SET, JAVA_WORKING_SET }); - return top; - } - - private void createEarComposite(Composite top) { - this.addToEarComposite = new AddToEarComposite(getDataModel(), 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 JpaFacet.ID; - } - - @Override - public void dispose() { - super.dispose(); - this.addToEarComposite.dispose(); - } - - @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(); -// } - - @Override - protected String[] getValidationPropertyNames() { - String[] superProperties = super.getValidationPropertyNames(); - List list = Arrays.asList(superProperties); - ArrayList<String> arrayList = new ArrayList<String>(); - arrayList.addAll(list); - arrayList.add(JpaProjectCreationDataModelProperties.EAR_PROJECT_NAME); - arrayList.add(JpaProjectCreationDataModelProperties.ADD_TO_EAR ); - return arrayList.toArray( new String[0] ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/model/JpaProjectCreationDataModelProperties.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/model/JpaProjectCreationDataModelProperties.java deleted file mode 100644 index 50968897b1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/model/JpaProjectCreationDataModelProperties.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards.proj.model; - -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; - -public interface JpaProjectCreationDataModelProperties - extends IFacetProjectCreationDataModelProperties { - - public static final String MODULE_FACET_DATA_MODEL - = "JpaProjectCreationDataModelProperties.MODULE_FACET_DATA_MODEL"; //$NON-NLS-1$ - - public static final String ADDED_UTILITY_FACET - = "JpaProjectCreationDataModelProperties.ADDED_UTILITY_FACET"; //$NON-NLS-1$ - - public static final String ADD_TO_EAR - = "JpaProjectCreationDataModelProperties.ADD_TO_EAR"; //$NON-NLS-1$ - - public static final String EAR_PROJECT_NAME - = "JpaProjectCreationDataModelProperties.EAR_PROJECT_NAME"; //$NON-NLS-1$ -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/model/JpaProjectCreationDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/model/JpaProjectCreationDataModelProvider.java deleted file mode 100644 index ba7fd01ca9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/proj/model/JpaProjectCreationDataModelProvider.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * 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.jpa.ui.internal.wizards.proj.model; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jpt.jpa.core.JpaFacet; -import org.eclipse.jpt.jpa.core.internal.facet.FacetTools; -import org.eclipse.jst.common.project.facet.core.JavaFacet; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProviderNew; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -public class JpaProjectCreationDataModelProvider - extends FacetProjectCreationDataModelProvider - implements JpaProjectCreationDataModelProperties { - - private IDataModelListener moduleFacetDataModelListener; - - - public JpaProjectCreationDataModelProvider() { - super(); - this.moduleFacetDataModelListener - = new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if (IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME.equals(event.getPropertyName())) { - if (isPropertySet(EAR_PROJECT_NAME)) { - setProperty(EAR_PROJECT_NAME, event.getProperty()); - } - else { - model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.DEFAULT_CHG); - } - } - else if (IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR.equals(event.getPropertyName())) { - setProperty(ADD_TO_EAR, event.getProperty()); - } - } - }; - } - - - @Override - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(MODULE_FACET_DATA_MODEL); - names.add(ADDED_UTILITY_FACET); - names.add(EAR_PROJECT_NAME); - names.add(ADD_TO_EAR); - return names; - } - - @Override - public void init() { - super.init(); - - Collection<IProjectFacet> requiredFacets = new ArrayList<IProjectFacet>(); - requiredFacets.add(JavaFacet.FACET); - requiredFacets.add(JpaFacet.FACET); - setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); - - getDataModel().addListener( - new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if (FACET_ACTION_MAP.equals(event.getPropertyName())) { - updateModuleFacetDataModel(); - } - } - }); - } - - @Override - public boolean isPropertyEnabled(String propertyName) { - if (FACET_RUNTIME.equals(propertyName)) { - if (isAddToEar()) { - IStatus status = validateEAR(model.getStringProperty(EAR_PROJECT_NAME)); - if (status.isOK()) { - IProject earProject = ProjectUtilities.getProject(getStringProperty(EAR_PROJECT_NAME)); - if (earProject != null) { - IFacetedProject facetedEarProject; - try { - facetedEarProject = ProjectFacetsManager.create(earProject); - if (facetedEarProject != null) { - return false; - } - } catch (CoreException e) { - J2EEPlugin.logError(e); - } - } - } - } - return true; - } - else if (EAR_PROJECT_NAME.equals(propertyName)) { - return isAddToEar(); - } - - return super.isPropertyEnabled(propertyName); - } - - @Override - public Object getDefaultProperty(String propertyName) { - if (ADDED_UTILITY_FACET.equals(propertyName)) { - return Boolean.FALSE; - } - else if (ADD_TO_EAR.equals(propertyName)) { - IDataModel moduleFacetDataModel = getModuleFacetDataModel(); - if (moduleFacetDataModel != null) { - return moduleFacetDataModel.getDefaultProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR); - } - } - else if (EAR_PROJECT_NAME.equals(propertyName)) { - IDataModel moduleFacetDataModel = getModuleFacetDataModel(); - if (moduleFacetDataModel !=null) { - return moduleFacetDataModel.getDefaultProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME); - } - } - - return super.getDefaultProperty(propertyName); - } - - @Override - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (FACET_RUNTIME.equals(propertyName) && isAddToEar()) { - DataModelPropertyDescriptor[] descriptors = super.getValidPropertyDescriptors(propertyName); - List list = new ArrayList(); - for (int i = 0; i < descriptors.length; i++) { - IRuntime rt = (IRuntime) descriptors[i].getPropertyValue(); - if (rt == null || rt.supports(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_FACET)) { - list.add(descriptors[i]); - } - } - descriptors = new DataModelPropertyDescriptor[list.size()]; - for (int i = 0; i < descriptors.length; i++) { - descriptors[i] = (DataModelPropertyDescriptor) list.get(i); - } - return descriptors; - } - else if (EAR_PROJECT_NAME.equals(propertyName)) { - IDataModel moduleFacetDataModel = getModuleFacetDataModel(); - if (moduleFacetDataModel != null) { - return moduleFacetDataModel.getValidPropertyDescriptors( - IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME); - } - else { - return new DataModelPropertyDescriptor[0]; - } - } - - return super.getValidPropertyDescriptors(propertyName); - } - - @Override - public boolean propertySet(String propertyName, Object propertyValue) { - if (EAR_PROJECT_NAME.equals(propertyName) || ADD_TO_EAR.equals(propertyName)) { - IDataModel moduleFacetDataModel = getModuleFacetDataModel(); - if (moduleFacetDataModel != null){ - if (EAR_PROJECT_NAME.equals(propertyName)) { - moduleFacetDataModel.setProperty( - IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME, propertyValue); - } - else { - moduleFacetDataModel.setProperty( - IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, propertyValue); - } - } - if (isAddToEar()) { - IStatus status = validateEAR(model.getStringProperty(EAR_PROJECT_NAME)); - if (status.isOK()) { - IProject earProject = ProjectUtilities.getProject(getStringProperty(EAR_PROJECT_NAME)); - if (earProject != null) { - IFacetedProject facetedEarProject; - try { - facetedEarProject = ProjectFacetsManager.create(earProject); - if (facetedEarProject != null) { - setProperty(FACET_RUNTIME, facetedEarProject.getPrimaryRuntime()); - } - } - catch (CoreException e) { - J2EEPlugin.logError(e); - } - } - } - } - if (ADD_TO_EAR.equals(propertyName)) { - this.model.notifyPropertyChange(FACET_RUNTIME, IDataModel.VALID_VALUES_CHG); - IProjectFacetVersion moduleFacet = findModuleFacet(); - if (isAddToEar()) { - if (moduleFacet == null) { - getFacetedProject().addProjectFacet(IJ2EEFacetConstants.UTILITY_FACET_10); - setBooleanProperty(ADDED_UTILITY_FACET, true); - } - } - else { - if (moduleFacet != null && isAddedUtilityFacet()) { - if (moduleFacet.equals(IJ2EEFacetConstants.UTILITY_FACET_10)) { - getFacetedProject().removeProjectFacet(IJ2EEFacetConstants.UTILITY_FACET_10); - } - setBooleanProperty(ADDED_UTILITY_FACET, false); - } - } - this.model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.ENABLE_CHG); - this.model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - this.model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.VALUE_CHG); - } - this.model.notifyPropertyChange(FACET_RUNTIME, IDataModel.ENABLE_CHG); - } - - return super.propertySet(propertyName, propertyValue); - } - - @Override - public IStatus validate(String propertyName) { - IStatus status = super.validate(propertyName); - - if (status == null) { - status = Status.OK_STATUS; - } - - if (! status.isOK()) { - return status; - } - - if (ADD_TO_EAR.equals(propertyName) || EAR_PROJECT_NAME.equals(propertyName) || FACET_PROJECT_NAME.equals(propertyName)) { - if (model.getBooleanProperty(ADD_TO_EAR)) { - status = validateEAR(model.getStringProperty(EAR_PROJECT_NAME)); - if (status.isOK()) { - if (getStringProperty(FACET_PROJECT_NAME).equals(getStringProperty(EAR_PROJECT_NAME))) { - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.SAME_MODULE_AND_EAR_NAME, new Object[]{getStringProperty(EAR_PROJECT_NAME)}); - status = WTPCommonPlugin.createErrorStatus(errorMessage); - } - } - } - } - - return status; - } - - protected IStatus validateEAR(String earName) { - if (earName.indexOf("#") != -1 || earName.indexOf("/") != -1) { //$NON-NLS-1$ //$NON-NLS-2$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_INVALID_CHARS); - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - else if (earName.equals("")) { //$NON-NLS-1$ - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_EMPTY_MODULE_NAME); - return WTPCommonPlugin.createErrorStatus(errorMessage); - } - - IStatus status = ProjectCreationDataModelProviderNew.validateProjectName(earName); - //check for the deleted case, the project is deleted from the workspace but still exists in the - //file system. - if (status.isOK()) { - IProject earProject = ProjectUtilities.getProject(getStringProperty(EAR_PROJECT_NAME)); - if (! earProject.exists()) { - IPath path = ResourcesPlugin.getWorkspace().getRoot().getLocation(); - path = path.append(earName); - status = ProjectCreationDataModelProviderNew.validateExisting(earName, path.toString()); - } - } - return status; - } - - protected void updateModuleFacetDataModel() { - IDataModel newModuleFacetDataModel = findModuleFacetDataModel(); - IDataModel oldModuleFacetDataModel = getModuleFacetDataModel(); - - if (oldModuleFacetDataModel != newModuleFacetDataModel) { - if (oldModuleFacetDataModel != null) { - oldModuleFacetDataModel.removeListener(this.moduleFacetDataModelListener); - } - if (newModuleFacetDataModel != null) { - newModuleFacetDataModel.setProperty( - IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, - getProperty(ADD_TO_EAR)); - newModuleFacetDataModel.setProperty( - IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME, - getProperty(EAR_PROJECT_NAME)); - newModuleFacetDataModel.addListener(this.moduleFacetDataModelListener); - } - else { - this.model.setBooleanProperty(ADD_TO_EAR, false); - this.model.setBooleanProperty(ADDED_UTILITY_FACET, false); - } - setProperty(MODULE_FACET_DATA_MODEL, newModuleFacetDataModel); - this.model.notifyPropertyChange(ADD_TO_EAR, IDataModel.DEFAULT_CHG); - this.model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.DEFAULT_CHG); - this.model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - } - } - - protected IFacetedProjectWorkingCopy getFacetedProject() { - return (IFacetedProjectWorkingCopy) this.model.getProperty(FACETED_PROJECT_WORKING_COPY); - } - - protected IDataModel getModuleFacetDataModel() { - return (IDataModel) getProperty(MODULE_FACET_DATA_MODEL); - } - - protected boolean isAddedUtilityFacet() { - return getBooleanProperty(ADDED_UTILITY_FACET); - } - - protected boolean isAddToEar() { - return getBooleanProperty(ADD_TO_EAR); - } - - protected IDataModel findModuleFacetDataModel() { - FacetActionMap map = (FacetActionMap) getProperty(FACET_ACTION_MAP); - IProjectFacetVersion moduleFacet = findModuleFacet(); - if (moduleFacet != null) { - IFacetedProject.Action action = map.getAction(moduleFacet.getProjectFacet().getId()); - return (action == null) ? null : (IDataModel) action.getConfig(); - } - return null; - } - - protected IProjectFacetVersion findModuleFacet() { - return FacetTools.getModuleFacet(getFacetedProject()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/jpa2/details/java/JavaUiFactory2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/jpa2/details/java/JavaUiFactory2_0.java deleted file mode 100644 index 32616e75f2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/jpa2/details/java/JavaUiFactory2_0.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.jpa2.details.java; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * Use {@link JavaUiFactory2_0} to create any java JPA composites - * <p> - * Provisional API: This interface is part of an interim API that is still under - * development and expected to change significantly before reaching stability. - * It is available at this early stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this API will almost - * certainly be broken (repeatedly) as the API evolves. - * - * - * @version 3.0 - * @since 3.0 - */ -public interface JavaUiFactory2_0 - extends JavaUiFactory -{ - - JpaComposite createJavaElementCollectionMapping2_0Composite( - PropertyValueModel<JavaElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/jpa2/details/orm/OrmXmlUiFactory2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/jpa2/details/orm/OrmXmlUiFactory2_0.java deleted file mode 100644 index 159a12dab1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/jpa2/details/orm/OrmXmlUiFactory2_0.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.jpa.ui.jpa2.details.orm; - -import org.eclipse.jpt.common.ui.WidgetFactory; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmElementCollectionMapping2_0; -import org.eclipse.jpt.jpa.ui.details.JpaComposite; -import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.swt.widgets.Composite; - -/** - * Use {@link OrmXmlUiFactory2_0} to create any ORM JPA composites - * <p> - * Provisional API: This interface is part of an interim API that is still under - * development and expected to change significantly before reaching stability. - * It is available at this early stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this API will almost - * certainly be broken (repeatedly) as the API evolves. - * - * @see org.eclipse.jpt.jpa.ui.internal.BaseJpaUiFactory - * - * @version 3.0 - * @since 3.0 - */ -public interface OrmXmlUiFactory2_0 extends OrmXmlUiFactory -{ - - JpaComposite createOrmElementCollectionMapping2_0Composite( - PropertyValueModel<OrmElementCollectionMapping2_0> subjectHolder, - Composite parent, - WidgetFactory widgetFactory); - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/navigator/JpaNavigatorProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/navigator/JpaNavigatorProvider.java deleted file mode 100644 index b221d6f1dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/navigator/JpaNavigatorProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.jpa.ui.navigator; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; - -/** - * This provider is responsible to create the Project Navigator view contents and - * labels for a given JPA project. - * - * @version 2.0 - * @since 2.0 - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaNavigatorProvider -{ - /** - * Build an factory to create {@link TreeItemContentProvider}s - */ - TreeItemContentProviderFactory getTreeItemContentProviderFactory(); - - /** - * Build a factory to create {@link ItemLabelProvider}s - */ - ItemLabelProviderFactory getItemLabelProviderFactory(); - - void dispose(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/structure/JpaStructureProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/structure/JpaStructureProvider.java deleted file mode 100644 index 5b6579d22b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/structure/JpaStructureProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 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.jpa.ui.structure; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; - -/** - * This provider is responsible to create the JPA Structure view contents and - * labels for a given JPA resource. - * - * @version 3.0 - * @since 2.0 - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JpaStructureProvider -{ - /** - * Build an factory to create {@link TreeItemContentProvider}s - */ - TreeItemContentProviderFactory getTreeItemContentProviderFactory(); - - /** - * Build a factory to create {@link ItemLabelProvider}s - */ - ItemLabelProviderFactory getItemLabelProviderFactory(); -} |