diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details')
185 files changed, 0 insertions, 24466 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractBasicMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractBasicMappingComposite.java deleted file mode 100644 index 2c9e61d7cb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractBasicMappingComposite.java +++ /dev/null @@ -1,268 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.BasicMapping; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.context.Converter; -import org.eclipse.jpt.core.context.ConvertibleMapping; -import org.eclipse.jpt.core.context.EnumeratedConverter; -import org.eclipse.jpt.core.context.TemporalConverter; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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.0 - * @since 1.0 - */ -public abstract class AbstractBasicMappingComposite<T extends BasicMapping> - extends FormPane<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) { - initializeGeneralPane(container); - initializeTypePane(container); - } - - protected void initializeGeneralPane(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new ColumnComposite(this, buildColumnHolder(), container); - - // Align the widgets under the ColumnComposite - container = addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - - new FetchTypeComposite(this, container); - new OptionalComposite(this, addSubPane(container, 4)); - - } - - private void initializeTypePane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.TypeSection_type - ); - ((GridLayout) container.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_default, - buildNoConverterHolder(), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - // Lob - Button lobButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_lob, - buildLobConverterHolder(), - null); - ((GridData) lobButton.getLayoutData()).horizontalSpan = 2; - - PropertyValueModel<Converter> specifiedConverterHolder = buildSpecifiedConverterHolder(); - // Temporal - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_temporal, - buildTemporalBooleanHolder(), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(specifiedConverterHolder), container, getWidgetFactory())); - - - // Enumerated - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_enumerated, - buildEnumeratedBooleanHolder(), - null); - registerSubPane(new EnumTypeComposite(buildEnumeratedConverterHolder(specifiedConverterHolder), container, getWidgetFactory())); - } - - protected PropertyValueModel<Column> buildColumnHolder() { - return new TransformationPropertyValueModel<T, Column>(getSubjectHolder()) { - @Override - protected Column transform_(T value) { - return value.getColumn(); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildNoConverterHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getSpecifiedConverter() == null); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.NO_CONVERTER); - } - } - }; - } - - private WritablePropertyValueModel<Boolean> buildLobConverterHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getSpecifiedConverter(); - if (converter == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(converter.getType() == Converter.LOB_CONVERTER); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.LOB_CONVERTER); - } - } - }; - } - - private PropertyValueModel<Converter> buildSpecifiedConverterHolder() { - return new PropertyAspectAdapter<T, Converter>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getSpecifiedConverter(); - } - }; - } - - private PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return (converter != null && converter.getType() == Converter.TEMPORAL_CONVERTER) ? (TemporalConverter) converter : null; - } - }; - } - - private PropertyValueModel<EnumeratedConverter> buildEnumeratedConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, EnumeratedConverter>(converterHolder) { - @Override - protected EnumeratedConverter transform_(Converter converter) { - return (converter != null && converter.getType() == Converter.ENUMERATED_CONVERTER) ? (EnumeratedConverter) converter : null; - } - }; - } - - private WritablePropertyValueModel<Boolean> buildTemporalBooleanHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getSpecifiedConverter(); - if (converter == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(converter.getType() == Converter.TEMPORAL_CONVERTER); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.TEMPORAL_CONVERTER); - } - } - }; - } - - private WritablePropertyValueModel<Boolean> buildEnumeratedBooleanHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getSpecifiedConverter(); - if (converter == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(converter.getType() == Converter.ENUMERATED_CONVERTER); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.ENUMERATED_CONVERTER); - } - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractBasicMappingUiDefinition.java deleted file mode 100644 index eb6e792fae..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractBasicMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.BasicMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - - -public abstract class AbstractBasicMappingUiDefinition<T extends BasicMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddableUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddableUiDefinition.java deleted file mode 100644 index 56ce259904..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddableUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.Embeddable; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractEmbeddableUiDefinition<T extends Embeddable> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedIdMappingUiDefinition.java deleted file mode 100644 index 352afb797e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - - -public abstract class AbstractEmbeddedIdMappingUiDefinition<T extends EmbeddedIdMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedMappingOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedMappingOverridesComposite.java deleted file mode 100644 index 151df30c0b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedMappingOverridesComposite.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.ui.internal.details; - -import org.eclipse.jpt.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.core.context.BaseEmbeddedMapping; -import org.eclipse.jpt.ui.internal.details.AbstractOverridesComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * @version 3.0 - * @since 3.0 - */ -public abstract class AbstractEmbeddedMappingOverridesComposite<T extends BaseEmbeddedMapping> extends AbstractOverridesComposite<T> -{ - - /** - * Creates a new <code>EmbeddedAttributeOverridesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - protected AbstractEmbeddedMappingOverridesComposite(FormPane<? 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(); - } - }; - } - - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedMappingUiDefinition.java deleted file mode 100644 index ff70a333ae..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEmbeddedMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.EmbeddedMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractEmbeddedMappingUiDefinition<T extends EmbeddedMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityComposite.java deleted file mode 100644 index 9e610fca0f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityComposite.java +++ /dev/null @@ -1,210 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.GeneratorContainer; -import org.eclipse.jpt.core.context.QueryContainer; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public abstract class AbstractEntityComposite<T extends Entity> extends FormPane<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 - */ - public AbstractEntityComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - protected abstract void addSecondaryTablesComposite(Composite container); - - protected abstract void addInheritanceComposite(Composite container); - - @Override - protected void initializeLayout(Composite container) { - - initializeGeneralPane(container); - initializeQueriesPane(container); - initializeInheritancePane(container); - initializeAttributeOverridesPane(container); - initializeGeneratorsPane(container); - initializeSecondaryTablesPane(container); - } - - protected void initializeGeneralPane(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new TableComposite(this, container); - new EntityNameComposite(this, addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin)); - new IdClassComposite(this, addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin), false); - } - - protected void initializeQueriesPane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.EntityComposite_queries - ); - - addQueriesComposite(container, buildQueryContainerHolder()); - } - - protected void addQueriesComposite(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 initializeAttributeOverridesPane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.OverridesComposite_attributeOverridesSection - ); - - addAttributeOverridesComposite(container); - } - - protected void addAttributeOverridesComposite(Composite container) { - new EntityOverridesComposite(this, container); - } - - protected void initializeInheritancePane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.EntityComposite_inheritance - ); - - addInheritanceComposite(container); - } - - protected void initializeGeneratorsPane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.IdMappingComposite_primaryKeyGenerationSection - ); - - addGeneratorsComposite(container, buildGeneratorContainer()); - } - - protected void addGeneratorsComposite(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 initializeSecondaryTablesPane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.SecondaryTablesComposite_secondaryTables - ); - - addSecondaryTablesComposite(container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityMappingsDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityMappingsDetailsProvider.java deleted file mode 100644 index 9325433331..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.context.orm.OrmStructureNodes; -import org.eclipse.jpt.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.utility.internal.StringTools; - -public abstract class AbstractEntityMappingsDetailsProvider - implements JpaDetailsProvider -{ - protected AbstractEntityMappingsDetailsProvider() { - super(); - } - - - public final boolean providesDetails(JpaStructureNode structureNode) { - return StringTools.stringsAreEqual(structureNode.getId(), OrmStructureNodes.ENTITY_MAPPINGS_ID) - && providesDetails(structureNode.getResourceType()); - } - - protected abstract boolean providesDetails(JpaResourceType resourceType); -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityOverridesComposite.java deleted file mode 100644 index 95b25e0c59..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityOverridesComposite.java +++ /dev/null @@ -1,90 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - Attribute Overrides --------------------------------------------------- | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | AddRemoveListPane | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | PageBook (AttributeOverrideComposite/AssociationOverrideComposite)| | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see EntityComposite - The parent container - * @see AttributeOverrideComposite - * @see AssociationOverrideComposite - * - * @version 3.0 - * @since 1.0 - */ -public abstract class AbstractEntityOverridesComposite extends AbstractOverridesComposite<Entity> -{ - - /** - * Creates a new <code>OverridesComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - protected AbstractEntityOverridesComposite(FormPane<? 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(); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityUiDefinition.java deleted file mode 100644 index 2ab02cd00b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractEntityUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractEntityUiDefinition<T extends Entity> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractIdMappingComposite.java deleted file mode 100644 index 83f5af7c3a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractIdMappingComposite.java +++ /dev/null @@ -1,164 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.context.Converter; -import org.eclipse.jpt.core.context.ConvertibleMapping; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.core.context.TemporalConverter; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | GenerationComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see IdMapping - * @see ColumnComposite - * @see TemporalTypeComposite - * @see IdMappingGenerationComposite - * - * @version 2.2 - * @since 1.0 - */ -public abstract class AbstractIdMappingComposite<T extends IdMapping> - extends FormPane<T> - implements JpaComposite -{ - /** - * Creates a new <code>IdMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IIdMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public AbstractIdMappingComposite(PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - protected PropertyValueModel<? extends Column> buildColumnHolder() { - return new TransformationPropertyValueModel<T, Column>(getSubjectHolder()) { - @Override - protected Column transform_(T value) { - return value.getColumn(); - } - }; - } - - protected void initializeTypePane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.TypeSection_type - ); - ((GridLayout) container.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_default, - buildNoConverterHolder(), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - PropertyValueModel<Converter> specifiedConverterHolder = buildSpecifiedConverterHolder(); - // Temporal - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_temporal, - buildTemporalBooleanHolder(), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(specifiedConverterHolder), container, getWidgetFactory())); - } - - protected WritablePropertyValueModel<Boolean> buildNoConverterHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getSpecifiedConverter() == null); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.NO_CONVERTER); - } - } - }; - } - - protected WritablePropertyValueModel<Boolean> buildTemporalBooleanHolder() { - return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getSpecifiedConverter(); - if (converter == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(converter.getType() == Converter.TEMPORAL_CONVERTER); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.TEMPORAL_CONVERTER); - } - } - }; - } - - protected PropertyValueModel<Converter> buildSpecifiedConverterHolder() { - return new PropertyAspectAdapter<T, Converter>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getSpecifiedConverter(); - } - }; - } - - protected PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return (converter != null && converter.getType() == Converter.TEMPORAL_CONVERTER) ? (TemporalConverter) converter : null; - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractIdMappingUiDefinition.java deleted file mode 100644 index 2e490da291..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractIdMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - - -public abstract class AbstractIdMappingUiDefinition<T extends IdMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractInheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractInheritanceComposite.java deleted file mode 100644 index 8990075456..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractInheritanceComposite.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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.InheritanceType; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.ColumnCombo; -import org.eclipse.jpt.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.StringConverter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.custom.CCombo; -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 FormPane<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(FormPane<? 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 - CCombo discriminatorValueCombo = addEditableCCombo( - subPane, - buildDiscriminatorValueListHolder(), - buildDiscriminatorValueHolder(), - buildDiscriminatorValueConverter() - ); - Label discriminatorValueLabel = addLabel( - subPane, - JptUiDetailsMessages.InheritanceComposite_discriminatorValue - ); - addLabeledComposite( - subPane, - discriminatorValueLabel, - discriminatorValueCombo.getParent(), - null, - JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_VALUE - ); - - SWTTools.controlEnabledState(buildDiscriminatorValueEnabledHolder(), discriminatorValueCombo, discriminatorValueLabel); - - 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) { - return null; - } - - 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( - JptUiDetailsMessages.DefaultWithOneParam, - defaultName - ); - } - else { - value = JptUiDetailsMessages.ProviderDefault; - } - } - if (value.startsWith(NONE_KEY)) { - value = JptUiDetailsMessages.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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractJoiningStrategyPane.java deleted file mode 100644 index fd487532c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractJoiningStrategyPane.java +++ /dev/null @@ -1,121 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.MappedByJoiningStrategy; -import org.eclipse.jpt.core.context.OwnableRelationshipReference; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 {@link OwnableRelationshipReference} - * @see {@link MappedByJoiningStrategy} - * @see {@link OneToOneJoiningStrategyPane} - * - * @version 3.0 - * @since 2.1 - */ -public abstract class AbstractJoiningStrategyPane - <R extends RelationshipReference, S extends JoiningStrategy> - extends FormPane<R> -{ - protected WritablePropertyValueModel<Boolean> usesStrategyHolder; - - protected PropertyValueModel<S> joiningStrategyHolder; - - protected Composite strategyDetailsComposite; - - - /** - * Creates a new <code>AbstractJoiningStrategyPane</code>. - * - * @param parentPane The parent form pane - * @param parent The parent container - */ - protected AbstractJoiningStrategyPane( - FormPane<? extends R> parentPane, - Composite parent) { - super(parentPane, parent); - } - - protected AbstractJoiningStrategyPane(FormPane<?> parentPane, - PropertyValueModel<? extends R> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initialize() { - super.initialize(); - this.usesStrategyHolder = buildUsesStrategyHolder(); - this.joiningStrategyHolder = buildJoiningStrategyHolder(); - } - - protected abstract WritablePropertyValueModel<Boolean> buildUsesStrategyHolder(); - - protected abstract PropertyValueModel<S> buildJoiningStrategyHolder(); - - @Override - protected void initializeLayout(Composite container) { - addRadioButton( - container, - getStrategyLabelKey(), - this.usesStrategyHolder, - null); - - 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.usesStrategyHolder, buildPageBookTransformer(), pageBook); - } - - protected abstract String getStrategyLabelKey(); - - 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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractJpaDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractJpaDetailsPage.java deleted file mode 100644 index 93f9c43b1e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractJpaDetailsPage.java +++ /dev/null @@ -1,53 +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.ui.internal.details; - -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.ui.JpaPlatformUi; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaDetailsPage; -import org.eclipse.jpt.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToManyMappingComposite.java deleted file mode 100644 index 208af11c64..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToManyMappingComposite.java +++ /dev/null @@ -1,114 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.AccessHolder; -import org.eclipse.jpt.core.context.Cascade; -import org.eclipse.jpt.core.context.ManyToManyMapping; -import org.eclipse.jpt.core.context.ManyToManyRelationshipReference; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public abstract class AbstractManyToManyMappingComposite<T extends ManyToManyMapping> - extends FormPane<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); - } - - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - } - - protected PropertyValueModel<ManyToManyRelationshipReference> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, ManyToManyRelationshipReference>( - getSubjectHolder()) { - @Override - protected ManyToManyRelationshipReference transform_(T value) { - return value.getRelationshipReference(); - } - }; - } - - 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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToManyMappingUiDefinition.java deleted file mode 100644 index 2b8b3aa2e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToManyMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.ManyToManyMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractManyToManyMappingUiDefinition<T extends ManyToManyMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToOneMappingComposite.java deleted file mode 100644 index 8e55459144..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToOneMappingComposite.java +++ /dev/null @@ -1,57 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Cascade; -import org.eclipse.jpt.core.context.ManyToOneMapping; -import org.eclipse.jpt.core.context.ManyToOneRelationshipReference; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractManyToOneMappingComposite<T extends ManyToOneMapping> - extends FormPane<T> - implements JpaComposite -{ - protected AbstractManyToOneMappingComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - protected PropertyValueModel<ManyToOneRelationshipReference> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, ManyToOneRelationshipReference>( - getSubjectHolder()) { - @Override - protected ManyToOneRelationshipReference transform_(T value) { - return value.getRelationshipReference(); - } - }; - } - - 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); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToOneMappingUiDefinition.java deleted file mode 100644 index 4ffe5eba66..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractManyToOneMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.ManyToOneMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractManyToOneMappingUiDefinition<T extends ManyToOneMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractMappedSuperclassUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractMappedSuperclassUiDefinition.java deleted file mode 100644 index d05278a02a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractMappedSuperclassUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.MappedSuperclass; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractMappedSuperclassUiDefinition<T extends MappedSuperclass> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToManyMappingComposite.java deleted file mode 100644 index ab8be0ea18..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToManyMappingComposite.java +++ /dev/null @@ -1,103 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Cascade; -import org.eclipse.jpt.core.context.OneToManyMapping; -import org.eclipse.jpt.core.context.OneToManyRelationshipReference; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public abstract class AbstractOneToManyMappingComposite<T extends OneToManyMapping> - extends FormPane<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); - } - - protected PropertyValueModel<OneToManyRelationshipReference> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, OneToManyRelationshipReference>(getSubjectHolder()) { - @Override - protected OneToManyRelationshipReference transform_(T value) { - return value.getRelationshipReference(); - } - }; - } - - 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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToManyMappingUiDefinition.java deleted file mode 100644 index d80e47b106..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToManyMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.OneToManyMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractOneToManyMappingUiDefinition<T extends OneToManyMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToOneMappingComposite.java deleted file mode 100644 index e7f40c6b4a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToOneMappingComposite.java +++ /dev/null @@ -1,57 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Cascade; -import org.eclipse.jpt.core.context.OneToOneMapping; -import org.eclipse.jpt.core.context.OneToOneRelationshipReference; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public abstract class AbstractOneToOneMappingComposite<T extends OneToOneMapping> - extends FormPane<T> - implements JpaComposite -{ - protected AbstractOneToOneMappingComposite( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - protected Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin); - } - - protected PropertyValueModel<OneToOneRelationshipReference> buildJoiningHolder() { - return new TransformationPropertyValueModel<T, OneToOneRelationshipReference>( - getSubjectHolder()) { - @Override - protected OneToOneRelationshipReference transform_(T value) { - return value.getRelationshipReference(); - } - }; - } - - 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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToOneMappingUiDefinition.java deleted file mode 100644 index 6fc75808cb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOneToOneMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.OneToOneMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractOneToOneMappingUiDefinition<T extends OneToOneMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOrderingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOrderingComposite.java deleted file mode 100644 index d1fb3df041..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOrderingComposite.java +++ /dev/null @@ -1,146 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.MultiRelationshipMapping; -import org.eclipse.jpt.core.context.Orderable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Ordering -------------------------------------------------------------- | - * | | | | - * | | o None | | - * | | | | - * | | o Primary Key | | - * | | | | - * | | o Custom | | - * | | ------------------------------------------------------------------- | | - * | | | I | | | - * | | ------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see MultiRelationshipMapping - * @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 FormPane<MultiRelationshipMapping> -{ - /** - * Creates a new <code>OrderingComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - protected AbstractOrderingComposite(FormPane<? extends MultiRelationshipMapping> 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 MultiRelationshipMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - - protected PropertyValueModel<Orderable> buildOrderableHolder() { - return new PropertyAspectAdapter<MultiRelationshipMapping, 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); - } - }; - } - - protected void installCustomTextEnabler(Text text, PropertyValueModel<Orderable> orderableHolder) { - PropertyValueModel<Boolean> enabler = buildCustomOrderingHolder(orderableHolder); - SWTTools.controlEnabledState(enabler, text); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOverridesComposite.java deleted file mode 100644 index 99bd4baf0d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractOverridesComposite.java +++ /dev/null @@ -1,443 +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.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.core.context.AssociationOverride; -import org.eclipse.jpt.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.core.context.AttributeOverride; -import org.eclipse.jpt.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.core.context.BaseOverride; -import org.eclipse.jpt.core.context.JpaContextNode; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.CachingTransformationWritablePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationWritablePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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> - * ----------------------------------------------------------------------------- - * | | - * | - Attribute Overrides --------------------------------------------------- | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | AddRemoveListPane | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | PageBook (attribute/association override composite) | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @version 3.0 - * @since 1.0 - */ -@SuppressWarnings("nls") -public abstract class AbstractOverridesComposite<T extends JpaContextNode> extends FormPane<T> -{ - private Pane<AttributeOverride> attributeOverridePane; - private Pane<AssociationOverride> associationOverridePane; - - private WritablePropertyValueModel<BaseOverride> selectedOverrideHolder; - private WritablePropertyValueModel<Boolean> overrideVirtualOverrideHolder; - - /** - * Creates a new <code>OverridesComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - protected AbstractOverridesComposite(FormPane<? extends T> parentPane, - Composite parent) { - - super(parentPane, parent, false); - } - - @Override - protected void initialize() { - super.initialize(); - this.selectedOverrideHolder = buildSelectedOverrideHolder(); - } - - private WritablePropertyValueModel<BaseOverride> buildSelectedOverrideHolder() { - return new SimplePropertyValueModel<BaseOverride>(); - } - - 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<BaseOverride, Boolean>(this.selectedOverrideHolder) { - @Override - protected Boolean transform(BaseOverride 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 container, 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<AttributeOverride> attributeOverrideHolder = buildAttributeOverrideHolder(); - this.attributeOverridePane = buildAttributeOverridePane(pageBook, attributeOverrideHolder); - installAttributeOverridePaneEnabler(this.attributeOverridePane, attributeOverrideHolder); - } - - protected Pane<AttributeOverride> buildAttributeOverridePane(PageBook pageBook, PropertyValueModel<AttributeOverride> attributeOverrideHolder) { - return new AttributeOverrideComposite(this, attributeOverrideHolder, pageBook); - } - - private void installAttributeOverridePaneEnabler(Pane<AttributeOverride> pane, PropertyValueModel<AttributeOverride> overrideHolder) { - new PaneEnabler( - buildOverrideBooleanHolder(overrideHolder), - pane - ); - } - - private PropertyValueModel<Boolean> buildOverrideBooleanHolder(PropertyValueModel<? extends BaseOverride> overrideHolder) { - return new CachingTransformationPropertyValueModel<BaseOverride, Boolean>(overrideHolder) { - @Override - protected Boolean transform_(BaseOverride value) { - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - protected void initializeAssociationOverridePane(PageBook pageBook) { - PropertyValueModel<AssociationOverride> associationOverrideHolder = buildAssociationOverrideHolder(); - this.associationOverridePane = buildAssociationOverridePane(pageBook, associationOverrideHolder); - installAssociationOverridePaneEnabler(this.associationOverridePane, associationOverrideHolder); - } - - protected Pane<AssociationOverride> buildAssociationOverridePane(PageBook pageBook, PropertyValueModel<AssociationOverride> associationOverrideHolder) { - return new AssociationOverrideComposite(this, associationOverrideHolder, pageBook); - } - - private void installAssociationOverridePaneEnabler(Pane<AssociationOverride> pane, PropertyValueModel<AssociationOverride> overrideHolder) { - new PaneEnabler( - buildOverrideBooleanHolder(overrideHolder), - pane - ); - } - - private void installOverrideControlSwitcher(PropertyValueModel<BaseOverride> overrideHolder, - PageBook pageBook) { - - new ControlSwitcher( - overrideHolder, - buildPaneTransformer(), - pageBook - ); - } - - private WritablePropertyValueModel<AssociationOverride> buildAssociationOverrideHolder() { - return new TransformationWritablePropertyValueModel<BaseOverride, AssociationOverride>(this.selectedOverrideHolder) { - @Override - protected AssociationOverride transform_(BaseOverride value) { - return (value instanceof AssociationOverride) ? (AssociationOverride) value : null; - } - }; - } - - private WritablePropertyValueModel<AttributeOverride> buildAttributeOverrideHolder() { - return new TransformationWritablePropertyValueModel<BaseOverride, AttributeOverride>(this.selectedOverrideHolder) { - @Override - protected AttributeOverride transform_(BaseOverride value) { - return (value instanceof AttributeOverride) ? (AttributeOverride) value : null; - } - }; - } - - private ListValueModel<AssociationOverride> buildDefaultAssociationOverridesListHolder(PropertyValueModel<AssociationOverrideContainer> containerHolder) { - return new ListAspectAdapter<AssociationOverrideContainer, AssociationOverride>(containerHolder, AssociationOverrideContainer.VIRTUAL_ASSOCIATION_OVERRIDES_LIST) { - @Override - protected ListIterator<AssociationOverride> listIterator_() { - return this.subject.virtualAssociationOverrides(); - } - - @Override - protected int size_() { - return this.subject.virtualAssociationOverridesSize(); - } - }; - } - - private ListValueModel<AttributeOverride> buildDefaultAttributeOverridesListHolder(PropertyValueModel<AttributeOverrideContainer> containerHolder) { - return new ListAspectAdapter<AttributeOverrideContainer, AttributeOverride>(containerHolder, AttributeOverrideContainer.VIRTUAL_ATTRIBUTE_OVERRIDES_LIST) { - @Override - protected ListIterator<AttributeOverride> listIterator_() { - return this.subject.virtualAttributeOverrides(); - } - - @Override - protected int size_() { - return this.subject.virtualAttributeOverridesSize(); - } - }; - } - - protected WritablePropertyValueModel<Boolean> getOverrideVirtualOverrideHolder() { - if (this.overrideVirtualOverrideHolder == null) { - this.overrideVirtualOverrideHolder = buildOverrideVirtualOverrideHolder(); - } - return this.overrideVirtualOverrideHolder; - } - - - private WritablePropertyValueModel<Boolean> buildOverrideVirtualOverrideHolder() { - return new CachingTransformationWritablePropertyValueModel<BaseOverride, Boolean>(this.selectedOverrideHolder) { - @Override - public void setValue(Boolean value) { - updateOverride(value.booleanValue()); - } - - @Override - protected Boolean transform_(BaseOverride value) { - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - private String buildOverrideDisplayString(BaseOverride override) { - String overrideType; - - // Retrieve the type - if (override instanceof AssociationOverride) { - 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((BaseOverride) 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<BaseOverride> buildOverridesListHolder() { - PropertyValueModel<AttributeOverrideContainer> attributeOverrideContainerHolder = buildAttributeOverrideContainerHolder(); - List<ListValueModel<? extends BaseOverride>> list = new ArrayList<ListValueModel<? extends BaseOverride>>(); - - 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 BaseOverride>, BaseOverride>(list); - } - - protected abstract PropertyValueModel<AttributeOverrideContainer> buildAttributeOverrideContainerHolder(); - - protected abstract PropertyValueModel<AssociationOverrideContainer> buildAssociationOverrideContainerHolder(); - - private ListValueModel<BaseOverride> buildOverridesListModel() { - return new ItemPropertyListValueModelAdapter<BaseOverride>( - buildOverridesListHolder(), - BaseOverride.NAME_PROPERTY - ); - } - - private Transformer<BaseOverride, Control> buildPaneTransformer() { - return new Transformer<BaseOverride, Control>() { - public Control transform(BaseOverride override) { - return AbstractOverridesComposite.this.transformSelectedOverride(override); - } - }; - } - - /** - * Given the selected override, return the control that will be displayed - */ - protected Control transformSelectedOverride(BaseOverride selectedOverride) { - if (selectedOverride instanceof AttributeOverride) { - return AbstractOverridesComposite.this.attributeOverridePane.getControl(); - } - - if (selectedOverride instanceof AssociationOverride) { - return AbstractOverridesComposite.this.associationOverridePane.getControl(); - } - - return null; - } - - private ListValueModel<AssociationOverride> buildSpecifiedAssociationOverridesListHolder(PropertyValueModel<AssociationOverrideContainer> containerHolder) { - return new ListAspectAdapter<AssociationOverrideContainer, AssociationOverride>(containerHolder, AssociationOverrideContainer.SPECIFIED_ASSOCIATION_OVERRIDES_LIST) { - @Override - protected ListIterator<AssociationOverride> listIterator_() { - return this.subject.specifiedAssociationOverrides(); - } - - @Override - protected int size_() { - return this.subject.specifiedAssociationOverridesSize(); - } - }; - } - - private ListValueModel<AttributeOverride> buildSpecifiedAttributeOverridesListHolder(PropertyValueModel<AttributeOverrideContainer> containerHolder) { - return new ListAspectAdapter<AttributeOverrideContainer, AttributeOverride>(containerHolder, AttributeOverrideContainer.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST) { - @Override - protected ListIterator<AttributeOverride> listIterator_() { - return this.subject.specifiedAttributeOverrides(); - } - - @Override - protected int size_() { - return this.subject.specifiedAttributeOverridesSize(); - } - }; - } - - private void updateOverride(boolean selected) { - - if (isPopulating()) { - return; - } - - setPopulating(true); - - try { - BaseOverride override = this.selectedOverrideHolder.getValue(); - - BaseOverride newOverride = override.setVirtual(!selected); - this.selectedOverrideHolder.setValue(newOverride); - } - finally { - setPopulating(false); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java deleted file mode 100644 index f8367c9cb9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java +++ /dev/null @@ -1,353 +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.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.core.context.BaseJoinColumn; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.AbstractAdapter; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 - * @see InheritanceComposite - The container of this pane - * - * @version 2.0 - * @since 2.0 - */ -public abstract class AbstractPrimaryKeyJoinColumnsComposite<T extends Entity> extends Pane<T> -{ - protected WritablePropertyValueModel<PrimaryKeyJoinColumn> joinColumnHolder; - - /** - * Creates a new <code>PrimaryKeyJoinColumnsComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - public AbstractPrimaryKeyJoinColumnsComposite(Pane<? extends T> subjectHolder, - Composite parent) { - - super(subjectHolder, parent, false); - } - - private void addJoinColumn(PrimaryKeyJoinColumnStateObject stateObject) { - - Entity subject = getSubject(); - int index = subject.specifiedPrimaryKeyJoinColumnsSize(); - - PrimaryKeyJoinColumn joinColumn = subject.addSpecifiedPrimaryKeyJoinColumn(index); - stateObject.updateJoinColumn(joinColumn); - } - - private 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 PrimaryKeyJoinColumn> 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>(); - } - - private String buildJoinColumnLabel(PrimaryKeyJoinColumn joinColumn) { - if (joinColumn.isVirtual()) { - 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((PrimaryKeyJoinColumn) element); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - private ListValueModel<PrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListHolder() { - List<ListValueModel<? extends PrimaryKeyJoinColumn>> list = new ArrayList<ListValueModel<? extends PrimaryKeyJoinColumn>>(); - list.add(buildSpecifiedJoinColumnsListHolder()); - list.add(buildDefaultJoinColumnsListHolder()); - return new CompositeListValueModel<ListValueModel<? extends PrimaryKeyJoinColumn>, PrimaryKeyJoinColumn>(list); - } - - private ListValueModel<PrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListModel() { - return new ItemPropertyListValueModelAdapter<PrimaryKeyJoinColumn>( - buildPrimaryKeyJoinColumnsListHolder(), - NamedColumn.SPECIFIED_NAME_PROPERTY, - NamedColumn.DEFAULT_NAME_PROPERTY, - BaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, - BaseJoinColumn.DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY - ); - } - - private ListValueModel<PrimaryKeyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<Entity, PrimaryKeyJoinColumn>(getSubjectHolder(), Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<PrimaryKeyJoinColumn> listIterator_() { - return subject.specifiedPrimaryKeyJoinColumns(); - } - - @Override - protected int size_() { - return subject.specifiedPrimaryKeyJoinColumnsSize(); - } - }; - } - - private void editJoinColumn(PrimaryKeyJoinColumnStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - private 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 - ); - } - - private 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); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractSecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractSecondaryTablesComposite.java deleted file mode 100644 index ded3534071..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractSecondaryTablesComposite.java +++ /dev/null @@ -1,179 +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.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.core.context.Entity; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.details.orm.OrmEntityComposite; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<T> -{ - /** - * Creates a new <code>SecondaryTablesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public AbstractSecondaryTablesComposite(FormPane<? 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(getControl().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(getControl().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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractTransientMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractTransientMappingUiDefinition.java deleted file mode 100644 index 9d05dd31c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractTransientMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.TransientMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractTransientMappingUiDefinition<T extends TransientMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AbstractVersionMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractVersionMappingComposite.java deleted file mode 100644 index 600d021469..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractVersionMappingComposite.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.ui.internal.details; - -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.context.Converter; -import org.eclipse.jpt.core.context.ConvertibleMapping; -import org.eclipse.jpt.core.context.TemporalConverter; -import org.eclipse.jpt.core.context.VersionMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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.0 - * @since 1.0 - */ -public abstract class AbstractVersionMappingComposite<T extends VersionMapping> - extends FormPane<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); - } - - protected PropertyValueModel<Column> buildColumnHolder() { - return new TransformationPropertyValueModel<T, Column>(getSubjectHolder()) { - @Override - protected Column transform_(T value) { - return value.getColumn(); - } - }; - } - - protected void initializeConversionPane(Composite container) { - - container = addCollapsableSection( - container, - JptUiDetailsMessages.TypeSection_type - ); - ((GridLayout) container.getLayout()).numColumns = 2; - - // No converter - Button noConverterButton = addRadioButton( - container, - JptUiDetailsMessages.TypeSection_default, - buildNoConverterHolder(), - null); - ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2; - - PropertyValueModel<Converter> specifiedConverterHolder = buildSpecifiedConverterHolder(); - // Temporal - addRadioButton( - container, - JptUiDetailsMessages.TypeSection_temporal, - buildTemporalBooleanHolder(), - null); - registerSubPane(new TemporalTypeComposite(buildTemporalConverterHolder(specifiedConverterHolder), container, getWidgetFactory())); - } - - - private WritablePropertyValueModel<Boolean> buildNoConverterHolder() { - return new PropertyAspectAdapter<VersionMapping, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - return Boolean.valueOf(this.subject.getSpecifiedConverter() == null); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.NO_CONVERTER); - } - } - }; - } - - - private WritablePropertyValueModel<Boolean> buildTemporalBooleanHolder() { - return new PropertyAspectAdapter<VersionMapping, Boolean>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Boolean buildValue_() { - Converter converter = this.subject.getSpecifiedConverter(); - if (converter == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(converter.getType() == Converter.TEMPORAL_CONVERTER); - } - - @Override - protected void setValue_(Boolean value) { - if (value.booleanValue()) { - this.subject.setSpecifiedConverter(Converter.TEMPORAL_CONVERTER); - } - } - }; - } - - private PropertyValueModel<Converter> buildSpecifiedConverterHolder() { - return new PropertyAspectAdapter<VersionMapping, Converter>(getSubjectHolder(), ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) { - @Override - protected Converter buildValue_() { - return this.subject.getSpecifiedConverter(); - } - }; - } - - private PropertyValueModel<TemporalConverter> buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) { - return new TransformationPropertyValueModel<Converter, TemporalConverter>(converterHolder) { - @Override - protected TemporalConverter transform_(Converter converter) { - return (converter != null && converter.getType() == Converter.TEMPORAL_CONVERTER) ? (TemporalConverter) converter : null; - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractVersionMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractVersionMappingUiDefinition.java deleted file mode 100644 index babb13dfcc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AbstractVersionMappingUiDefinition.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.ui.internal.details; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.VersionMapping; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.swt.graphics.Image; - -public abstract class AbstractVersionMappingUiDefinition<T extends VersionMapping> - implements MappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/AccessTypeComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AccessTypeComposite.java deleted file mode 100644 index bf1fb8df05..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AccessTypeComposite.java +++ /dev/null @@ -1,119 +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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.context.AccessHolder; -import org.eclipse.jpt.core.context.AccessType; -import org.eclipse.jpt.ui.internal.JptUiMessages; -import org.eclipse.jpt.ui.internal.details.orm.OrmEmbeddableComposite; -import org.eclipse.jpt.ui.internal.details.orm.OrmEntityComposite; -import org.eclipse.jpt.ui.internal.details.orm.OrmMappedSuperclassComposite; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 FormPane<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(FormPane<?> parentPane, - PropertyValueModel<? extends AccessHolder> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - public AccessTypeComposite(FormPane<?> 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.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java deleted file mode 100644 index 969ba9279a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java +++ /dev/null @@ -1,186 +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.ui.internal.details; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.jpt.core.context.Query; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog; -import org.eclipse.jpt.utility.internal.StringConverter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.StaticListValueModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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> { - - - // ********** constructors ********** - - /** - * Use this constructor to edit an existing conversion value - */ - public AddQueryDialog(Shell parent) { - super(parent); - } - - @Override - protected AddQueryStateObject buildStateObject() { - return new AddQueryStateObject(); - } - - // ********** 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(Query.NAMED_QUERY); - queryTypes.add(Query.NAMED_NATIVE_QUERY); - - return new StaticListValueModel<String>(queryTypes); - } - - private StringConverter<String> buildStringConverter() { - return new StringConverter<String>() { - public String convertToString(String value) { - if (value == Query.NAMED_QUERY) { - return JptUiDetailsMessages.AddQueryDialog_namedQuery; - } - if (value == Query.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.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java deleted file mode 100644 index 9dd862cff1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java +++ /dev/null @@ -1,124 +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.ui.internal.details; - -import java.util.List; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.node.AbstractNode; -import org.eclipse.jpt.utility.internal.node.Node; -import org.eclipse.jpt.utility.internal.node.Problem; - -/** - * 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; - - /** - * 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() { - super(null); - - } - - private void addNameProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.name)) { - currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_nameMustBeSpecified)); - } - } - - private void addQueryTypeProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.queryType)) { - currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_typeMustBeSpecified)); - } - } - - @Override - protected void addProblemsTo(List<Problem> currentProblems) { - super.addProblemsTo(currentProblems); - addNameProblemsTo(currentProblems); - addQueryTypeProblemsTo(currentProblems); - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/AssociationOverrideComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AssociationOverrideComposite.java deleted file mode 100644 index d6e61bdb91..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AssociationOverrideComposite.java +++ /dev/null @@ -1,81 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.AssociationOverride; -import org.eclipse.jpt.core.context.AssociationOverrideRelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * 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 FormPane<AssociationOverride> -{ - - /** - * 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(FormPane<?> parentPane, - PropertyValueModel<? extends AssociationOverride> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - // joining strategy group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title - ); - - addJoinColumnJoiningStrategyPane(groupPane); - } - - protected void addJoinColumnJoiningStrategyPane(Composite container) { - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithoutIncludeOverrideCheckBox( - this, - buildRelationshipReferenceHolder(), - container); - } - - private PropertyValueModel<AssociationOverrideRelationshipReference> buildRelationshipReferenceHolder() { - return new TransformationPropertyValueModel<AssociationOverride, AssociationOverrideRelationshipReference>(getSubjectHolder()) { - @Override - protected AssociationOverrideRelationshipReference transform_(AssociationOverride value) { - return value.getRelationshipReference(); - } - }; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AttributeOverrideComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AttributeOverrideComposite.java deleted file mode 100644 index 398b53046f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AttributeOverrideComposite.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.ui.internal.details; - -import org.eclipse.jpt.core.context.AttributeOverride; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 FormPane<AttributeOverride> -{ - - /** - * 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(FormPane<?> parentPane, - PropertyValueModel<? extends AttributeOverride> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - new ColumnComposite( - this, - buildColumnHolder(), - container, - false - ); - } - - private PropertyValueModel<Column> buildColumnHolder() { - return new TransformationPropertyValueModel<AttributeOverride, Column>(getSubjectHolder()) { - @Override - protected Column transform_(AttributeOverride value) { - return value.getColumn(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnDialog.java deleted file mode 100644 index 7e5e921881..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnDialog.java +++ /dev/null @@ -1,109 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.BaseJoinColumn; -import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog; -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 BaseJoinColumn 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, - BaseJoinColumn 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 BaseJoinColumn 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.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnDialogPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnDialogPane.java deleted file mode 100644 index 34f768a095..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnDialogPane.java +++ /dev/null @@ -1,441 +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.ui.internal.details; - -import java.util.ArrayList; -import java.util.ListIterator; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.SWTUtil; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.utility.internal.StringConverter; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 JoinColumnInJoinTableDialog - 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( - JptUiDetailsMessages.DefaultWithOneParam, - defaultName - ); - } - else { - value = JptUiDetailsMessages.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.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnStateObject.java deleted file mode 100644 index 870fb96382..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BaseJoinColumnStateObject.java +++ /dev/null @@ -1,396 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.BaseJoinColumn; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.utility.internal.node.AbstractNode; -import org.eclipse.jpt.utility.internal.node.Node; - -/** - * 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 BaseJoinColumn 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, BaseJoinColumn 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.sortedColumnIdentifiers()).listIterator(); - } - - private static int columnsSize(Table table) { - if (table == null) { - return 0; - } - return table.columnsSize(); - } - - 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() { - if (this.joinColumn == null) { - return null; - } - - return 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 BaseJoinColumn 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, BaseJoinColumn 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) { - String oldTable = this.table; - this.table = table; - firePropertyChanged(TABLE_PROPERTY, oldTable, table); - tableChanged(); - } - - @Override - public final void setValidator(Validator validator) { - this.validator = validator; - } - - /** - * The table from which the column names are used has changed, notifies the - * listeners the list of names and reference column names should be updated. - */ - protected void tableChanged() { - fireListChanged(NAMES_LIST, CollectionTools.list(this.names())); - fireListChanged(REFERENCE_COLUMN_NAMES_LIST, CollectionTools.list(this.referenceColumnNames())); - } - - /** - * 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.ui/src/org/eclipse/jpt/ui/internal/details/BasicMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/BasicMappingComposite.java deleted file mode 100644 index 54a9776958..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import org.eclipse.jpt.core.context.BasicMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/CascadeComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/CascadeComposite.java deleted file mode 100644 index ab6800d789..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/CascadeComposite.java +++ /dev/null @@ -1,198 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Cascade; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 extends FormPane<Cascade> -{ - /** - * 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(FormPane<? extends RelationshipMapping> parentPane, - PropertyValueModel<? extends Cascade> 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<? extends Cascade> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - private 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); - } - }; - } - - private 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); - } - }; - } - - private 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); - } - }; - } - - private 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); - } - }; - } - - private 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); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Cascade group - Group cascadeGroup = addTitledGroup( - container, - JptUiDetailsMessages.CascadeComposite_cascadeTitle - ); - - // Container of the check boxes - container = addSubPane(cascadeGroup, 5, 8, 0, 0, 0); - - // All check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_all, - buildCascadeTypeAllHolder(), - null - ); - - // Persist check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_persist, - buildCascadeTypePersistHolder(), - null - ); - - // Merge check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_merge, - buildCascadeTypeMergeHolder(), - null - ); - - // Remove check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_remove, - buildCascadeTypeRemoveHolder(), - null - ); - - // Refresh check box - addCheckBox( - container, - JptUiDetailsMessages.CascadeComposite_refresh, - buildCascadeTypeRefreshHolder(), - null - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ColumnComposite.java deleted file mode 100644 index 594da1dd16..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ColumnComposite.java +++ /dev/null @@ -1,640 +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.ui.internal.details; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.core.context.BaseColumn; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.ColumnCombo; -import org.eclipse.jpt.ui.internal.details.db.DatabaseObjectCombo; -import org.eclipse.jpt.ui.internal.details.db.TableCombo; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnCombo | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TableCombo | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | > Details | - * | | - * | x Insertable | - * | | - * | x Updatable | - * | | - * | x Unique | - * | | - * | x Nullable | - * | | - * | --------------- | - * | Length: | I |I| Default (XXX) | - * | --------------- | - * | --------------- | - * | Precision: | I |I| Default (XXX) | - * | --------------- | - * | --------------- | - * | Scale: | I |I| Default (XXX) | - * | --------------- | - * | ---------------------------------------------------- | - * | Column Definition: | I | | - * | ---------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Column - * @see ColumnCombo - * @see TableCombo - * @see BasicMappingComposite - A container of this pane - * @see EmbeddedMappingOverridesComposite - 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 ColumnComposite extends FormPane<Column> { - - /** - * 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 ColumnComposite(FormPane<?> parentPane, - PropertyValueModel<? extends Column> 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 ColumnComposite(FormPane<?> parentPane, - PropertyValueModel<? extends Column> 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 ColumnComposite(FormPane<?> parentPane, - PropertyValueModel<? extends Column> subjectHolder, - Composite parent, - boolean automaticallyAlignWidgets, - boolean parentManagePane) { - - super(parentPane, subjectHolder, parent, automaticallyAlignWidgets, parentManagePane); - } - - private ColumnCombo<Column> addColumnCombo(Composite container) { - - return new ColumnCombo<Column>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(NamedColumn.DEFAULT_NAME_PROPERTY); - propertyNames.add(NamedColumn.SPECIFIED_NAME_PROPERTY); - propertyNames.add(BaseColumn.DEFAULT_TABLE_PROPERTY); - propertyNames.add(BaseColumn.SPECIFIED_TABLE_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - if (propertyName == BaseColumn.DEFAULT_TABLE_PROPERTY || - propertyName == BaseColumn.SPECIFIED_TABLE_PROPERTY) { - this.doPopulate(); - } else { - super.propertyChanged(propertyName); - } - } - - @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 "ColumnComposite.columnCombo"; //$NON-NLS-1$ - } - }; - } - - private WritablePropertyValueModel<String> buildColumnDefinitionHolder() { - return new PropertyAspectAdapter<Column, 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<Column, 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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_insertableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_insertable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultInsertableHolder() { - return new PropertyAspectAdapter<Column, 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<Column, 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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_nullableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_nullable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultNullableHolder() { - return new PropertyAspectAdapter<Column, 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 Pane<Column> addTableCombo(Composite container) { - - return new DatabaseObjectCombo<Column>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(BaseColumn.DEFAULT_TABLE_PROPERTY); - propertyNames.add(BaseColumn.SPECIFIED_TABLE_PROPERTY); - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultTable(); - } - - @Override - protected void setValue(String value) { - this.getSubject().setSpecifiedTable(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedTable(); - } - - @Override - protected Iterator<String> values() { - return this.getSubject().getOwner().getTypeMapping().associatedTableNamesIncludingInherited(); - } - @Override - public String toString() { - return "ColumnComposite.tableCombo"; //$NON-NLS-1$ - } - }; - } - - private WritablePropertyValueModel<Boolean> buildUniqueHolder() { - return new PropertyAspectAdapter<Column, Boolean>( - getSubjectHolder(), - BaseColumn.SPECIFIED_UNIQUE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - return this.subject.getSpecifiedUnique(); - } - - @Override - protected void setValue_(Boolean value) { - this.subject.setSpecifiedUnique(value); - } - }; - } - - private PropertyValueModel<String> buildUniqueStringHolder() { - - return new TransformationPropertyValueModel<Boolean, String>(buildDefaultUniqueHolder()) { - - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_uniqueWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_unique; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultUniqueHolder() { - return new PropertyAspectAdapter<Column, Boolean>( - getSubjectHolder(), - BaseColumn.SPECIFIED_UNIQUE_PROPERTY, - BaseColumn.DEFAULT_UNIQUE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedUnique() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultUnique()); - } - }; - } - - private WritablePropertyValueModel<Boolean> buildUpdatableHolder() { - return new PropertyAspectAdapter<Column, 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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.ColumnComposite_updatableWithDefault, defaultStringValue); - } - return JptUiDetailsMessages.ColumnComposite_updatable; - } - }; - } - - private PropertyValueModel<Boolean> buildDefaultUpdatableHolder() { - return new PropertyAspectAdapter<Column, 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 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 = addCollapsableSubSection( - container, - JptUiDetailsMessages.ColumnComposite_details, - new SimplePropertyValueModel<Boolean>(Boolean.FALSE) - ); - - new DetailsComposite(this, getSubjectHolder(), addSubPane(container, 0, 16)); - } - - protected class DetailsComposite extends FormPane<Column> { - - public DetailsComposite(FormPane<?> parentPane, - PropertyValueModel<? extends Column> 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<Column>(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<Column, Integer>(getSubjectHolder(), Column.DEFAULT_LENGTH_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultLength()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_LENGTH_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedLength(); - } - - @Override - protected void setValue_(Integer value) { - this.subject.setSpecifiedLength(value); - } - }; - } - }; - } - - private void addPrecisionCombo(Composite container) { - new IntegerCombo<Column>(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<Column, Integer>(getSubjectHolder(), Column.DEFAULT_PRECISION_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultPrecision()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_PRECISION_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedPrecision(); - } - - @Override - protected void setValue_(Integer value) { - this.subject.setSpecifiedPrecision(value); - } - }; - } - }; - } - - private void addScaleCombo(Composite container) { - new IntegerCombo<Column>(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<Column, Integer>(getSubjectHolder(), Column.DEFAULT_SCALE_PROPERTY) { - @Override - protected Integer buildValue_() { - return Integer.valueOf(this.subject.getDefaultScale()); - } - }; - } - - @Override - protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() { - return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_SCALE_PROPERTY) { - @Override - protected Integer buildValue_() { - return this.subject.getSpecifiedScale(); - } - - @Override - protected void setValue_(Integer value) { - this.subject.setSpecifiedScale(value); - } - }; - } - }; - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/DiscriminatorColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/DiscriminatorColumnComposite.java deleted file mode 100644 index f05cc89ea4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/DiscriminatorColumnComposite.java +++ /dev/null @@ -1,307 +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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.context.DiscriminatorColumn; -import org.eclipse.jpt.core.context.DiscriminatorType; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.ColumnCombo; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<T> { - - /** - * Creates a new <code>InheritanceComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public DiscriminatorColumnComposite(FormPane<? 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 = addCollapsableSubSection( - 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 JptUiDetailsMessages.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 JptUiDetailsMessages.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 FormPane<DiscriminatorColumn> { - public DetailsComposite(FormPane<?> 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.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddableComposite.java deleted file mode 100644 index a7db563848..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddableComposite.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.ui.internal.details; - -import org.eclipse.jpt.core.context.Embeddable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * This pane does not have any widgets. - * - * @see Embeddable - * @see EmbeddableUiProvider - * - * @version 2.0 - * @since 2.0 - */ -public class EmbeddableComposite extends FormPane<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 EmbeddableComposite(PropertyValueModel<? extends Embeddable> 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.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedIdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedIdMappingComposite.java deleted file mode 100644 index e483cbe832..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedIdMappingComposite.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.ui.internal.details; - -import org.eclipse.jpt.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here's the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedIdMapping - * - * @version 3.0 - * @since 1.0 - */ -public class EmbeddedIdMappingComposite extends FormPane<EmbeddedIdMapping> - implements JpaComposite -{ - /** - * Creates a new <code>EmbeddedIdMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>EmbeddedIdMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public EmbeddedIdMappingComposite(PropertyValueModel<? extends EmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - new EmbeddedMappingOverridesComposite( - this, - container - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedMappingComposite.java deleted file mode 100644 index b07ccc6057..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedMappingComposite.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.ui.internal.details; - -import org.eclipse.jpt.core.context.EmbeddedMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | EmbeddedAttributeOverridesComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * - * @version 3.0 - * @since 1.0 - */ -public class EmbeddedMappingComposite extends FormPane<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); - } - - @Override - protected void initializeLayout(Composite container) { - - new EmbeddedMappingOverridesComposite( - this, - container - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedMappingOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedMappingOverridesComposite.java deleted file mode 100644 index 58fb070398..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EmbeddedMappingOverridesComposite.java +++ /dev/null @@ -1,82 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.core.context.BaseEmbeddedMapping; -import org.eclipse.jpt.core.context.EmbeddedMapping; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | | - * | x Override Default | - * | | - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see EmbeddedMapping - * @see EmbeddedMappingComposite - The parent container - * @see ColumnComposite - * - * @version 3.0 - * @since 1.0 - */ -public class EmbeddedMappingOverridesComposite extends AbstractEmbeddedMappingOverridesComposite<BaseEmbeddedMapping> -{ - - /** - * Creates a new <code>EmbeddedAttributeOverridesComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public EmbeddedMappingOverridesComposite(FormPane<? 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(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EntityNameComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EntityNameComposite.java deleted file mode 100644 index f33c51ee50..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EntityNameComposite.java +++ /dev/null @@ -1,120 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.SWTUtil; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.custom.CCombo; -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.0 - * @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) { - - CCombo combo = addLabeledEditableCCombo( - 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( - JptUiDetailsMessages.DefaultWithOneParam, - defaultValue - ); - } - return JptUiDetailsMessages.DefaultEmpty; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EntityOverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EntityOverridesComposite.java deleted file mode 100644 index ed0983fd27..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EntityOverridesComposite.java +++ /dev/null @@ -1,61 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | - Attribute Overrides --------------------------------------------------- | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | AddRemoveListPane | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | PageBook (AttributeOverrideComposite/AssociationOverrideComposite)| | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see EntityComposite - The parent container - * @see AttributeOverrideComposite - * @see AssociationOverrideComposite - * - * @version 3.0 - * @since 1.0 - */ -public class EntityOverridesComposite extends AbstractEntityOverridesComposite -{ - - /** - * Creates a new <code>OverridesComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - public EntityOverridesComposite(FormPane<? extends Entity> parentPane, - Composite parent) { - - super(parentPane, parent); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EnumTypeComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EnumTypeComposite.java deleted file mode 100644 index ce0b9d1730..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/EnumTypeComposite.java +++ /dev/null @@ -1,114 +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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.context.BasicMapping; -import org.eclipse.jpt.core.context.EnumType; -import org.eclipse.jpt.core.context.EnumeratedConverter; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 FormPane<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.ui/src/org/eclipse/jpt/ui/internal/details/FetchTypeComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/FetchTypeComposite.java deleted file mode 100644 index 9e6ad1d354..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/FetchTypeComposite.java +++ /dev/null @@ -1,107 +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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.context.FetchType; -import org.eclipse.jpt.core.context.Fetchable; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------ | - * | Fetch: | |v| | - * | ------------------------------------------------------------------ | - * -----------------------------------------------------------------------------</pre> - * - * @see Fetchable - * @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 FormPane<Fetchable> { - - /** - * Creates a new <code>FetchTypeComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public FetchTypeComposite(FormPane<? extends Fetchable> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - private EnumFormComboViewer<Fetchable, FetchType> addFetchTypeCombo(Composite container) { - - return new EnumFormComboViewer<Fetchable, FetchType>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(Fetchable.DEFAULT_FETCH_PROPERTY); - propertyNames.add(Fetchable.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.ui/src/org/eclipse/jpt/ui/internal/details/GeneratedValueComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/GeneratedValueComposite.java deleted file mode 100644 index 3dd43fbc7b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/GeneratedValueComposite.java +++ /dev/null @@ -1,366 +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.ui.internal.details; - -import java.util.Collection; - -import org.eclipse.jpt.core.context.GeneratedValue; -import org.eclipse.jpt.core.context.GenerationType; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.listeners.SWTListChangeListenerWrapper; -import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.event.ListChangeEvent; -import org.eclipse.jpt.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.utility.model.listener.ListChangeAdapter; -import org.eclipse.jpt.utility.model.listener.ListChangeListener; -import org.eclipse.jpt.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -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.2 - * @since 1.0 - */ -@SuppressWarnings("nls") -public class GeneratedValueComposite extends FormPane<IdMapping> -{ - private PropertyChangeListener generatedValuePropertyChangeListener; - private CCombo generatorNameCombo; - private PropertyChangeListener generatorNamePropertyChangeListener; - private ListChangeListener generatorsListChangeListener; - - /** - * Creates a new <code>GeneratedValueComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public GeneratedValueComposite(FormPane<? extends IdMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - private PropertyChangeListener buildGeneratedValuePropertyChangeListener() { - return new SWTPropertyChangeListenerWrapper( - buildGeneratedValuePropertyChangeListener_() - ); - } - - private PropertyChangeListener buildGeneratedValuePropertyChangeListener_() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent e) { - disengageListeners((GeneratedValue) e.getOldValue()); - engageListeners((GeneratedValue) e.getNewValue()); - - if (!isPopulating()) { - setPopulating(true); - - try { - populateGeneratorNameCombo(); - } - finally { - setPopulating(false); - } - } - } - }; - } - - private ModifyListener buildGeneratorNameModifyListener() { - return new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (isPopulating()) { - return; - } - - String generatorName = ((CCombo) e.getSource()).getText(); - GeneratedValue generatedValue = getSubject().getGeneratedValue(); - - if (StringTools.stringIsEmpty(generatorName)) { - - if ((generatedValue == null) || - StringTools.stringIsEmpty(generatedValue.getGenerator())) - { - return; - } - - generatorName = null; - } - - retrieveGeneratedValue().setSpecifiedGenerator(generatorName); - } - }; - } - - private PropertyChangeListener buildGeneratorNamePropertyChangeListener() { - return new SWTPropertyChangeListenerWrapper( - buildGeneratorNamePropertyChangeListener_() - ); - } - - private PropertyChangeListener buildGeneratorNamePropertyChangeListener_() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent e) { - if (!isPopulating()) { - setPopulating(true); - - try { - populateGeneratorName(); - } - finally { - setPopulating(false); - } - } - } - }; - } - - private ListChangeListener buildGeneratorsListChangeListener() { - return new SWTListChangeListenerWrapper( - buildGeneratorsListChangeListener_()); - } - - private ListChangeListener buildGeneratorsListChangeListener_() { - return new ListChangeAdapter() { - @Override - // should only have to listen to this event - others aren't created - public void listChanged(ListChangeEvent event) { - if (! isPopulating()) { - setPopulating(true); - - try { - populateGeneratorChoices(); - } - finally { - setPopulating(false); - } - } - - } - }; - } - - private PropertyValueModel<GeneratedValue> buildGeneratorValueHolder() { - return new PropertyAspectAdapter<IdMapping, GeneratedValue>(getSubjectHolder(), IdMapping.GENERATED_VALUE_PROPERTY) { - @Override - protected GeneratedValue buildValue_() { - return getSubject().getGeneratedValue(); - } - }; - } - - private EnumFormComboViewer<GeneratedValue, GenerationType> addStrategyComboViewer(Composite parent) { - - return new EnumFormComboViewer<GeneratedValue, GenerationType>(this, buildGeneratorValueHolder(), 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); - } - }; - } - - @Override - protected void doPopulate() { - super.doPopulate(); - populateGeneratorNameCombo(); - } - - @Override - protected void engageListeners_(IdMapping subject) { - super.engageListeners_(subject); - subject.addPropertyChangeListener(IdMapping.GENERATED_VALUE_PROPERTY, this.generatedValuePropertyChangeListener); - this.engageListeners(subject.getGeneratedValue()); - } - - private void engageListeners(GeneratedValue generatedValue) { - if (generatedValue != null) { - this.engageListeners_(generatedValue); - } - } - - private void engageListeners_(GeneratedValue generatedValue) { - generatedValue.getPersistenceUnit().addListChangeListener(PersistenceUnit.GENERATORS_LIST, this.generatorsListChangeListener); - generatedValue.addPropertyChangeListener(GeneratedValue.DEFAULT_GENERATOR_PROPERTY, this.generatorNamePropertyChangeListener); - generatedValue.addPropertyChangeListener(GeneratedValue.SPECIFIED_GENERATOR_PROPERTY, this.generatorNamePropertyChangeListener); - } - - @Override - protected void disengageListeners_(IdMapping subject) { - this.disengageListeners(subject.getGeneratedValue()); - subject.removePropertyChangeListener(IdMapping.GENERATED_VALUE_PROPERTY, this.generatedValuePropertyChangeListener); - super.disengageListeners_(subject); - } - - private void disengageListeners(GeneratedValue generatedValue) { - if (generatedValue != null) { - this.disengageListeners_(generatedValue); - } - } - - private void disengageListeners_(GeneratedValue generatedValue) { - generatedValue.removePropertyChangeListener(GeneratedValue.SPECIFIED_GENERATOR_PROPERTY, this.generatorNamePropertyChangeListener); - generatedValue.removePropertyChangeListener(GeneratedValue.DEFAULT_GENERATOR_PROPERTY, this.generatorNamePropertyChangeListener); - generatedValue.getPersistenceUnit().removeListChangeListener(PersistenceUnit.GENERATORS_LIST, this.generatorsListChangeListener); - } - - @Override - protected void initialize() { - super.initialize(); - - this.generatedValuePropertyChangeListener = buildGeneratedValuePropertyChangeListener(); - this.generatorNamePropertyChangeListener = buildGeneratorNamePropertyChangeListener(); - this.generatorsListChangeListener = buildGeneratorsListChangeListener(); - } - - @Override - protected void initializeLayout(Composite container) { - - // Strategy widgets - addLabeledComposite( - container, - JptUiDetailsMessages.GeneratedValueComposite_strategy, - addStrategyComboViewer(container), - JpaHelpContextIds.MAPPING_GENERATED_VALUE_STRATEGY - ); - - // Generator Name widgets - this.generatorNameCombo = addLabeledEditableCCombo( - container, - JptUiDetailsMessages.GeneratedValueComposite_generatorName, - buildGeneratorNameModifyListener(), - JpaHelpContextIds.MAPPING_GENERATED_VALUE_STRATEGY - ); - - this.generatorNameCombo.add(JptUiDetailsMessages.DefaultEmpty); - } - - private void populateGeneratorChoices() { - if (this.generatorNameCombo.isDisposed()) { - return; - } - if (getSubject() == null) { - this.generatorNameCombo.setItems(new String[0]); - } - else { - this.generatorNameCombo.setItems(this.sortedUniqueGeneratorNames()); - } - } - - private void populateGeneratorName() { - if (this.generatorNameCombo.isDisposed()) { - return; - } - if (getSubject() == null) { - this.generatorNameCombo.setText(""); - } - else { - GeneratedValue generatedValue = getSubject().getGeneratedValue(); - - if (generatedValue == null) { - this.generatorNameCombo.setText(""); - } - else { - String generatorName = generatedValue.getGenerator(); - - if (StringTools.stringIsEmpty(generatorName)) { - this.generatorNameCombo.setText(""); - } - else if (!this.generatorNameCombo.getText().equals(generatorName)) { - this.generatorNameCombo.setText(generatorName); - } - } - } - } - - private void populateGeneratorNameCombo() { - populateGeneratorName(); - populateGeneratorChoices(); - } - - private GeneratedValue retrieveGeneratedValue() { - GeneratedValue generatedValue = getSubject().getGeneratedValue(); - - if (generatedValue == null) { - setPopulating(true); - - try { - generatedValue = getSubject().addGeneratedValue(); - } - finally { - setPopulating(false); - } - } - - return generatedValue; - } - - private String[] sortedUniqueGeneratorNames() { - return ArrayTools.sort(this.getSubject().getPersistenceUnit().uniqueGeneratorNames()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/GenerationComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/GenerationComposite.java deleted file mode 100644 index d672118b76..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import org.eclipse.jpt.core.context.GeneratorContainer; -import org.eclipse.jpt.core.context.SequenceGenerator; -import org.eclipse.jpt.core.context.TableGenerator; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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.addCollapsableSubSection( - 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 = addCollapsableSubSection( - 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.ui/src/org/eclipse/jpt/ui/internal/details/GeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/GeneratorComposite.java deleted file mode 100644 index 6571f2b676..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.Generator; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.ui.internal.widgets.IntegerCombo; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/IdClassComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdClassComposite.java deleted file mode 100644 index 4f77f9a536..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdClassComposite.java +++ /dev/null @@ -1,113 +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.ui.internal.details; - -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.IdClassHolder; -import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | | - * | ClassChooserPane | - * | | - * -----------------------------------------------------------------------------</pre> - * - * @see IdClass - * @see ClassChooserPane - * @see AbstractEntityComposite - A parent container - * @see MappedSuperclassComposite - A parent container - * - * @version 2.0 - * @since 2.0 - */ -public class IdClassComposite extends Pane<IdClassHolder> -{ - /** - * Creates a new <code>IdClassComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public IdClassComposite(Pane<? extends IdClassHolder> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - public IdClassComposite(Pane<? extends IdClassHolder> parentPane, - Composite parent, - boolean automaticallyAlignWidgets) { - - super(parentPane, parent, automaticallyAlignWidgets); - } - - private ClassChooserPane<IdClassHolder> addClassChooser(Composite container) { - - return new ClassChooserPane<IdClassHolder>(this, container) { - - @Override - protected WritablePropertyValueModel<String> buildTextHolder() { - return new PropertyAspectAdapter<IdClassHolder, String>(getSubjectHolder(), IdClassHolder.ID_CLASS_PROPERTY) { - @Override - protected String buildValue_() { - return this.subject.getIdClass(); - } - - @Override - protected void setValue_(String value) { - - if (value.length() == 0) { - value = null; - } - - this.subject.setIdClass(value); - } - }; - } - - @Override - protected String getClassName() { - return getSubject().getIdClass(); - } - - @Override - protected String getLabelText() { - return JptUiDetailsMessages.IdClassComposite_label; - } - - @Override - protected JpaProject getJpaProject() { - return getSubject().getJpaProject(); - } - - @Override - protected void setClassName(String className) { - getSubject().setIdClass(className); - } - - @Override - protected char getEnclosingTypeSeparator() { - return getSubject().getIdClassEnclosingTypeSeparator(); - } - }; - } - - @Override - protected void initializeLayout(Composite container) { - addClassChooser(container); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdMappingComposite.java deleted file mode 100644 index 1864b5ddb7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdMappingComposite.java +++ /dev/null @@ -1,74 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | GenerationComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see IdMapping - * @see ColumnComposite - * @see TemporalTypeComposite - * @see IdMappingGenerationComposite - * - * @version 2.2 - * @since 1.0 - */ -public class IdMappingComposite extends AbstractIdMappingComposite<IdMapping> -{ - /** - * Creates a new <code>IdMappingComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IIdMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public IdMappingComposite(PropertyValueModel<? extends IdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - // Column widgets - new ColumnComposite(this, buildColumnHolder(), container); - - initializeTypePane(container); - - // Generation pane - new IdMappingGenerationComposite(this, addSubPane(container, 10)); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdMappingGenerationComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdMappingGenerationComposite.java deleted file mode 100644 index 427b39cf75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/IdMappingGenerationComposite.java +++ /dev/null @@ -1,348 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.GeneratedValue; -import org.eclipse.jpt.core.context.GeneratorContainer; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.core.context.SequenceGenerator; -import org.eclipse.jpt.core.context.TableGenerator; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<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(FormPane<? 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 = addCollapsableSection( - 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 = addCollapsableSubSection( - 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 = addCollapsableSubSection( - 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.ui/src/org/eclipse/jpt/ui/internal/details/InverseJoinColumnInJoinTableDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/InverseJoinColumnInJoinTableDialog.java deleted file mode 100644 index 1e3bc32bac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/InverseJoinColumnInJoinTableDialog.java +++ /dev/null @@ -1,88 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -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, - JoinTable joinTable, - JoinColumn joinColumn) { - - super(parent, joinTable, joinColumn); - } - - /* - * non-Javadoc) - */ - @Override - protected DialogPane<InverseJoinColumnInJoinTableStateObject> buildLayout(Composite container) { - return new JoinColumnDialogPane<InverseJoinColumnInJoinTableStateObject>( - getSubjectHolder(), - container - ) - - { - @Override - protected boolean isTableEditable() { - return false; - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected InverseJoinColumnInJoinTableStateObject buildStateObject() { - return new InverseJoinColumnInJoinTableStateObject( - getOwner(), - getJoinColumn() - ); - } - - /* - * (non-Javadoc) - */ - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } - - /* - * (non-Javadoc) - */ - @Override - protected JoinTable getOwner() { - return (JoinTable) super.getOwner(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/InverseJoinColumnInJoinTableStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/InverseJoinColumnInJoinTableStateObject.java deleted file mode 100644 index f3320dab04..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/InverseJoinColumnInJoinTableStateObject.java +++ /dev/null @@ -1,100 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -/** - * 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.0 - * @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 Schema getDbSchema() { - return null; - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnDialog.java deleted file mode 100644 index 070b8f1f35..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnDialog.java +++ /dev/null @@ -1,56 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -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, JoinColumn joinColumn) { - super(parent, owner, joinColumn); - } - - /* - * (non-Javadoc) - */ - @Override - protected DialogPane<?> buildLayout(Composite container) { - return new JoinColumnDialogPane<T>(getSubjectHolder(), container); - } - - /* - * (non-Javadoc) - */ - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnDialogPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnDialogPane.java deleted file mode 100644 index 116ad329b5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnDialogPane.java +++ /dev/null @@ -1,285 +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.ui.internal.details; - -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.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.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoinTableDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoinTableDialog.java deleted file mode 100644 index a656ead946..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoinTableDialog.java +++ /dev/null @@ -1,89 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -/** - * This dialog is used to either create or edit a joing column that is located - * on a join table. - * - * @see JoinColumn - * @see JoinTable - * @see JoinColumnInJoinTableStateObject - * @see BaseJoinColumnDialogPane - * - * @version 2.0 - * @since 1.0 - */ -public class JoinColumnInJoinTableDialog extends BaseJoinColumnDialog<JoinColumnInJoinTableStateObject> { - - /** - * Creates a new <code>JoinColumnInJoinTableDialog</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 JoinColumnInJoinTableDialog(Shell parent, - JoinTable joinTable, - JoinColumn joinColumn) { - - super(parent, joinTable, joinColumn); - } - - /* - * non-Javadoc) - */ - @Override - protected DialogPane<JoinColumnInJoinTableStateObject> buildLayout(Composite container) { - return new JoinColumnDialogPane<JoinColumnInJoinTableStateObject>( - getSubjectHolder(), - container - ) { - @Override - protected boolean isTableEditable() { - return false; - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected JoinColumnInJoinTableStateObject buildStateObject() { - return new JoinColumnInJoinTableStateObject( - getOwner(), - getJoinColumn() - ); - } - - /* - * (non-Javadoc) - */ - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } - - /* - * (non-Javadoc) - */ - @Override - protected JoinTable getOwner() { - return (JoinTable) super.getOwner(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoinTableStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoinTableStateObject.java deleted file mode 100644 index 167986c1ae..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoinTableStateObject.java +++ /dev/null @@ -1,94 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -/** - * 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 JoinColumnInJoinTableDialog - * - * @version 2.0 - * @since 2.0 - */ -public class JoinColumnInJoinTableStateObject - 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 JoinColumnInJoinTableStateObject( - 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(); - return relationshipMapping == null ? null : - relationshipMapping.getTypeMapping().getPrimaryDbTable(); - } - - @Override - protected Schema getDbSchema() { - return null; - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoiningStrategyDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoiningStrategyDialog.java deleted file mode 100644 index 5cf6d41b6f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoiningStrategyDialog.java +++ /dev/null @@ -1,66 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy; -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 JoinColumnJoiningStrategy - * @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, - JoinColumnJoiningStrategy joinColumnOwner, - JoinColumn joinColumn) { - - super(parent, joinColumnOwner, joinColumn); - } - - /* - * (non-Javadoc) - */ - @Override - protected JoinColumnInJoiningStrategyStateObject buildStateObject() { - return new JoinColumnInJoiningStrategyStateObject( - getOwner(), - getJoinColumn() - ); - } - - /* - * (non-Javadoc) - */ - @Override - protected JoinColumnJoiningStrategy getOwner() { - return (JoinColumnJoiningStrategy) super.getOwner(); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoiningStrategyStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoiningStrategyStateObject.java deleted file mode 100644 index fd83cac218..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnInJoiningStrategyStateObject.java +++ /dev/null @@ -1,112 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; - -/** - * The state object used to create or edit a primary key join column on a - * relationship mapping. - * - * @see JoinColumn - * @see JoinColumnJoiningStrategy - * @see JoinColumnInJoiningStrategyDialog - * - * @version 3.0 - * @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( - JoinColumnJoiningStrategy joiningStrategy, - JoinColumn joinColumn) { - super(joiningStrategy, joinColumn); - } - - - @Override - public JoinColumnJoiningStrategy getOwner() { - return (JoinColumnJoiningStrategy) super.getOwner(); - } - - private RelationshipReference getRelationshipReference() { - return getOwner().getRelationshipReference(); - } - - private RelationshipMapping getRelationshipMapping() { - return getRelationshipReference().getRelationshipMapping(); - } - - private TypeMapping getTypeMapping() { - return getOwner().getTypeMapping(); - } - - @Override - public String getDefaultTable() { - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.getDefaultTable(); - } - - return getTypeMapping().getPrimaryTableName(); - } - - @Override - public Table getNameTable() { - Schema schema = this.getDbSchema(); - if (schema == null) { - return null; - } - - String tableIdentifier = this.getTable(); - if (tableIdentifier == null) { - tableIdentifier = this.getDefaultTable(); - } - - return schema.getTableForIdentifier(tableIdentifier); - } - - @Override - public Table getReferencedNameTable() { - RelationshipMapping relationshipMapping = getRelationshipMapping(); - - if (relationshipMapping == null){ - return null; - } - Entity targetEntity = relationshipMapping.getResolvedTargetEntity(); - - if (targetEntity != null) { - return targetEntity.getPrimaryDbTable(); - } - - return null; - } - - @Override - public Schema getDbSchema() { - return getTypeMapping().getDbSchema(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnJoiningStrategyPane.java deleted file mode 100644 index 09b9cb3b52..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnJoiningStrategyPane.java +++ /dev/null @@ -1,151 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Join columns __________________________________________________________ | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoiningStrategyJoinColumnsComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link JoinColumnEnabledRelationshipReference} - * @see {@link JoinColumnJoiningStrategy} - * @see {@link OneToOneJoiningStrategyPane} - * @see {@link ManyToOneJoiningStrategyPane} - * - * @version 3.0 - * @since 2.1 - */ -public class JoinColumnJoiningStrategyPane - extends AbstractJoiningStrategyPane - <JoinColumnEnabledRelationshipReference, JoinColumnJoiningStrategy> -{ - - private final boolean includeOverrideCheckBox; - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox( - FormPane<? extends JoinColumnEnabledRelationshipReference> parentPane, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, parent, true); - } - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithoutIncludeOverrideCheckBox( - FormPane<? extends JoinColumnEnabledRelationshipReference> parentPane, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, parent, false); - } - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox( - FormPane<?> parentPane, - PropertyValueModel<? extends JoinColumnEnabledRelationshipReference> subjectHolder, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, subjectHolder, parent, true); - } - - public static JoinColumnJoiningStrategyPane buildJoinColumnJoiningStrategyPaneWithoutIncludeOverrideCheckBox( - FormPane<?> parentPane, - PropertyValueModel<? extends JoinColumnEnabledRelationshipReference> subjectHolder, - Composite parent) { - return new JoinColumnJoiningStrategyPane(parentPane, subjectHolder, parent, false); - } - - private JoinColumnJoiningStrategyPane( - FormPane<? extends JoinColumnEnabledRelationshipReference> parentPane, - Composite parent, - boolean includeOverrideCheckBox) { - super(parentPane, parent); - this.includeOverrideCheckBox = includeOverrideCheckBox; - initializeLayout2(getControl()); - } - - private JoinColumnJoiningStrategyPane(FormPane<?> parentPane, - PropertyValueModel<? extends JoinColumnEnabledRelationshipReference> 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 WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return new PropertyAspectAdapter<JoinColumnEnabledRelationshipReference, Boolean>( - this.getSubjectHolder(), RelationshipReference.PREDOMINANT_JOINING_STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.usesJoinColumnJoiningStrategy()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setJoinColumnJoiningStrategy(); - } - else { - this.subject.unsetJoinColumnJoiningStrategy(); - } - } - }; - } - - @Override - protected PropertyValueModel<JoinColumnJoiningStrategy> buildJoiningStrategyHolder() { - return new PropertyAspectAdapter - <JoinColumnEnabledRelationshipReference, JoinColumnJoiningStrategy>( - getSubjectHolder()) { - @Override - protected JoinColumnJoiningStrategy buildValue_() { - return this.subject.getJoinColumnJoiningStrategy(); - } - }; - } - - @Override - protected String getStrategyLabelKey() { - return JptUiDetailsMessages.Joining_joinColumnJoiningLabel; - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - if (this.includeOverrideCheckBox) { - return new JoiningStrategyJoinColumnsWithOverrideOptionComposite(this, this.joiningStrategyHolder, parent).getControl(); - } - return new JoiningStrategyJoinColumnsComposite(this, this.joiningStrategyHolder, parent).getControl(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnStateObject.java deleted file mode 100644 index cf43023462..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnStateObject.java +++ /dev/null @@ -1,217 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.BaseColumn; -import org.eclipse.jpt.core.context.BaseJoinColumn; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * 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, JoinColumn joinColumn) { - super(owner, joinColumn); - } - - public boolean isDefaultInsertable() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultInsertable(); - } - - return BaseColumn.DEFAULT_INSERTABLE; - } - - public boolean isDefaultNullable() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultNullable(); - } - - return BaseColumn.DEFAULT_NULLABLE; - } - - public boolean isDefaultUnique() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultUnique(); - } - - return BaseColumn.DEFAULT_UNIQUE; - } - - public boolean isDefaultUpdatable() { - - JoinColumn joinColumn = getJoinColumn(); - - if (joinColumn != null) { - return joinColumn.isDefaultUpdatable(); - } - - return BaseColumn.DEFAULT_UPDATABLE; - } - - public Boolean getInsertable() { - return this.insertable; - } - - @Override - public JoinColumn getJoinColumn() { - return (JoinColumn) super.getJoinColumn(); - } - - public Boolean getNullable() { - return this.nullable; - } - - protected abstract Schema getDbSchema(); - - public Boolean getUnique() { - return this.unique; - } - - public Boolean getUpdatable() { - return this.updatable; - } - - @Override - protected void initialize(Object owner, BaseJoinColumn baseJoinColumn) { - - super.initialize(owner, baseJoinColumn); - - if (baseJoinColumn != null) { - JoinColumn joinColumn = (JoinColumn) 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() { - Schema schema = getDbSchema(); - if (schema == null) { - return EmptyListIterator.instance(); - } - return CollectionTools.list(schema.sortedTableIdentifiers()).listIterator(); - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnsComposite.java deleted file mode 100644 index b735c67f0c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinColumnsComposite.java +++ /dev/null @@ -1,330 +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.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.core.JpaNode; -import org.eclipse.jpt.core.context.BaseJoinColumn; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.AbstractAdapter; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<T> -{ - /** - * The editor used to perform the common behaviors defined in the list pane. - */ - private 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 widgetFactory The factory used to create various common widgets - * @param joinColumnsEditor The editor used to perform the common behaviors - * defined in the list pane - */ - public JoinColumnsComposite(FormPane<? 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 widgetFactory The factory used to create various common widgets - * @param joinColumnsEditor The editor used to perform the common behaviors - * defined in the list pane - */ - public JoinColumnsComposite(FormPane<?> 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>(); - } - - private String buildJoinColumnLabel(JoinColumn joinColumn) { - - if (joinColumn.isVirtual()) { - 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<JoinColumn> buildJoinColumnsListModel() { - return new ItemPropertyListValueModelAdapter<JoinColumn>(buildJoinColumnsListHolder(), - NamedColumn.SPECIFIED_NAME_PROPERTY, - NamedColumn.DEFAULT_NAME_PROPERTY, - BaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, - BaseJoinColumn.DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY); - } - - private ListValueModel<JoinColumn> buildJoinColumnsListHolder() { - java.util.List<ListValueModel<JoinColumn>> list = new ArrayList<ListValueModel<JoinColumn>>(); - list.add(buildSpecifiedJoinColumnsListHolder()); - list.add(buildDefaultJoinColumnListHolder()); - return new CompositeListValueModel<ListValueModel<JoinColumn>, JoinColumn>(list); - } - - private ListValueModel<JoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<T, JoinColumn>(getSubjectHolder(), this.joinColumnsEditor.getSpecifiedJoinColumnsListPropertyName()) { - @Override - protected ListIterator<JoinColumn> listIterator_() { - return JoinColumnsComposite.this.joinColumnsEditor.specifiedJoinColumns(this.subject); - } - - @Override - protected int size_() { - return JoinColumnsComposite.this.joinColumnsEditor.specifiedJoinColumnsSize(this.subject); - } - }; - } - - - private ListValueModel<JoinColumn> buildDefaultJoinColumnListHolder() { - return new PropertyListValueModelAdapter<JoinColumn>(buildDefaultJoinColumnHolder()); - - } - - private PropertyValueModel<JoinColumn> buildDefaultJoinColumnHolder() { - return new PropertyAspectAdapter<T, JoinColumn>(getSubjectHolder(), this.joinColumnsEditor.getDefaultPropertyName()) { - @Override - protected JoinColumn buildValue_() { - return JoinColumnsComposite.this.joinColumnsEditor.getDefaultJoinColumn(this.subject); - } - }; - } - - - private ILabelProvider buildJoinColumnsListLabelProvider() { - return new LabelProvider() { - @Override - public String getText(Object element) { - JoinColumn joinColumn = (JoinColumn) element; - - return buildJoinColumnLabel(joinColumn); - } - }; - } - - protected 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, JoinColumn joinColumn); - - /** - * Return whether the subject has specified join columns - */ - boolean hasSpecifiedJoinColumns(T subject); - - /** - * Return the spcified join columns from the given subject - */ - ListIterator<JoinColumn> 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. - */ - JoinColumn 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.ui/src/org/eclipse/jpt/ui/internal/details/JoinTableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinTableComposite.java deleted file mode 100644 index 9b4347ef3b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinTableComposite.java +++ /dev/null @@ -1,763 +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.ui.internal.details; - -import java.util.Collection; -import java.util.ListIterator; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.JoinColumnsComposite.JoinColumnsEditor; -import org.eclipse.jpt.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.ui.internal.details.db.TableCombo; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper; -import org.eclipse.jpt.utility.internal.model.value.ValueListAdapter; -import org.eclipse.jpt.utility.model.event.StateChangeEvent; -import org.eclipse.jpt.utility.model.listener.StateChangeListener; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 {@link JoinTable} - * @see {@link JoinTableJoiningStrategyPane} - * @see {@link JoinColumnsComposite - * - * @version 2.1 - * @since 1.0 - */ -public class JoinTableComposite extends FormPane<JoinTable> -{ - private Button overrideDefaultInverseJoinColumnsCheckBox; - private Button overrideDefaultJoinColumnsCheckBox; - - private JoinColumnsComposite<JoinTable> joinColumnsComposite; - private JoinColumnsComposite<JoinTable> 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( - FormPane<?> parentPane, - PropertyValueModel<? extends JoinTable> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - /** - * 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 JoinTable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - - int groupBoxMargin = getGroupBoxMargin(); - - // Name widgets - TableCombo<JoinTable> tableCombo = addTableCombo(container); - Composite tablePane = addPane(container, groupBoxMargin); - addLabeledComposite( - tablePane, - JptUiDetailsMessages.JoinTableComposite_name, - tableCombo.getControl(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_NAME - ); - - // schema widgets - SchemaCombo<JoinTable> schemaCombo = addSchemaCombo(container); - - addLabeledComposite( - tablePane, - JptUiDetailsMessages.JoinTableComposite_schema, - schemaCombo.getControl(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_SCHEMA - ); - - // catalog widgets - CatalogCombo<JoinTable> 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<JoinTable>( - 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<JoinTable>( - this, - inverseJoinColumnGroupPane, - buildInverseJoinColumnsEditor() - ); - - installInverseJoinColumnsPaneEnabler(this.inverseJoinColumnsComposite); - } - - private void installInverseJoinColumnsPaneEnabler(JoinColumnsComposite<JoinTable> pane) { - pane.installJoinColumnsPaneEnabler(new InverseJoinColumnPaneEnablerHolder()); - } - - private void installJoinColumnsPaneEnabler(JoinColumnsComposite<JoinTable> pane) { - pane.installJoinColumnsPaneEnabler(new JoinColumnPaneEnablerHolder()); - } - - private void addInverseJoinColumn(JoinTable joinTable) { - - InverseJoinColumnInJoinTableDialog dialog = - new InverseJoinColumnInJoinTableDialog(getShell(), joinTable, null); - - dialog.openDialog(buildAddInverseJoinColumnPostExecution()); - } - - private void addInverseJoinColumnFromDialog(InverseJoinColumnInJoinTableStateObject stateObject) { - - JoinTable subject = 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 void addJoinColumn(JoinTable joinTable) { - - JoinColumnInJoinTableDialog dialog = - new JoinColumnInJoinTableDialog(getShell(), joinTable, null); - - dialog.openDialog(buildAddJoinColumnPostExecution()); - } - - private void addJoinColumnFromDialog(JoinColumnInJoinTableStateObject stateObject) { - - JoinTable subject = getSubject(); - int index = subject.specifiedJoinColumnsSize(); - - JoinColumn joinColumn = getSubject().addSpecifiedJoinColumn(index); - stateObject.updateJoinColumn(joinColumn); - this.setSelectedJoinColumn(joinColumn); - } - - private void setSelectedJoinColumn(JoinColumn joinColumn) { - this.joinColumnsComposite.setSelectedJoinColumn(joinColumn); - } - - private PostExecution<InverseJoinColumnInJoinTableDialog> buildAddInverseJoinColumnPostExecution() { - return new PostExecution<InverseJoinColumnInJoinTableDialog>() { - public void execute(InverseJoinColumnInJoinTableDialog dialog) { - if (dialog.wasConfirmed()) { - addInverseJoinColumnFromDialog(dialog.getSubject()); - } - } - }; - } - - private PostExecution<JoinColumnInJoinTableDialog> buildAddJoinColumnPostExecution() { - return new PostExecution<JoinColumnInJoinTableDialog>() { - public void execute(JoinColumnInJoinTableDialog dialog) { - if (dialog.wasConfirmed()) { - addJoinColumnFromDialog(dialog.getSubject()); - } - } - }; - } - - private PostExecution<InverseJoinColumnInJoinTableDialog> buildEditInverseJoinColumnPostExecution() { - return new PostExecution<InverseJoinColumnInJoinTableDialog>() { - public void execute(InverseJoinColumnInJoinTableDialog dialog) { - if (dialog.wasConfirmed()) { - editInverseJoinColumn(dialog.getSubject()); - } - } - }; - } - - private PostExecution<JoinColumnInJoinTableDialog> buildEditJoinColumnPostExecution() { - return new PostExecution<JoinColumnInJoinTableDialog>() { - public void execute(JoinColumnInJoinTableDialog dialog) { - if (dialog.wasConfirmed()) { - editJoinColumn(dialog.getSubject()); - } - } - }; - } - - private InverseJoinColumnsProvider buildInverseJoinColumnsEditor() { - return new InverseJoinColumnsProvider(); - } - - private JoinColumnsProvider buildJoinColumnsEditor() { - return new JoinColumnsProvider(); - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultInverseJoinColumnHolder() { - return new OverrideDefaultInverseJoinColumnHolder(); - } - - private ListValueModel<JoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<JoinTable, JoinColumn>(getSubjectHolder(), JoinTable.SPECIFIED_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<JoinColumn> listIterator_() { - return this.subject.specifiedJoinColumns(); - } - - @Override - protected int size_() { - return this.subject.specifiedJoinColumnsSize(); - } - }; - } - - private ListValueModel<JoinColumn> buildSpecifiedInverseJoinColumnsListHolder() { - return new ListAspectAdapter<JoinTable, JoinColumn>(getSubjectHolder(), JoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<JoinColumn> listIterator_() { - return this.subject.specifiedInverseJoinColumns(); - } - - @Override - protected int size_() { - return this.subject.specifiedInverseJoinColumnsSize(); - } - }; - } - - private Composite addPane(Composite container, int groupBoxMargin) { - return addSubPane(container, 0, groupBoxMargin, 10, groupBoxMargin); - } - - private TableCombo<JoinTable> addTableCombo(Composite container) { - - return new TableCombo<JoinTable>(this, 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(); - } - - }; - } - - private SchemaCombo<JoinTable> addSchemaCombo(Composite container) { - - return new SchemaCombo<JoinTable>(this, container) { - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - 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_CATALOG_PROPERTY - || propertyName == Table.SPECIFIED_CATALOG_PROPERTY ) { - repopulate(); - } - } - - @Override - protected String getDefaultValue() { - return this.getSubject().getDefaultSchema(); - } - - @Override - protected void setValue(String value) { - this.getSubject().setSpecifiedSchema(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedSchema(); - } - - @Override - protected SchemaContainer getDbSchemaContainer_() { - return this.getSubject().getDbSchemaContainer(); - } - }; - } - - private CatalogCombo<JoinTable> addCatalogCombo(Composite container) { - - return new CatalogCombo<JoinTable>(this, 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 this.getSubject().getDefaultCatalog(); - } - - @Override - protected void setValue(String value) { - this.getSubject().setSpecifiedCatalog(value); - } - - @Override - protected String getValue() { - return this.getSubject().getSpecifiedCatalog(); - } - }; - } - - private void editInverseJoinColumn(InverseJoinColumnInJoinTableStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - private void editInverseJoinColumn(JoinColumn joinColumn) { - - InverseJoinColumnInJoinTableDialog dialog = - new InverseJoinColumnInJoinTableDialog(getShell(), getSubject(), joinColumn); - - dialog.openDialog(buildEditInverseJoinColumnPostExecution()); - } - - private void editJoinColumn(JoinColumn joinColumn) { - - JoinColumnInJoinTableDialog dialog = - new JoinColumnInJoinTableDialog(getShell(), getSubject(), joinColumn); - - dialog.openDialog(buildEditJoinColumnPostExecution()); - } - - private void editJoinColumn(JoinColumnInJoinTableStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - private void updateInverseJoinColumns() { - if (this.isPopulating()) { - return; - } - - 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); - } - } - - private void updateJoinColumns() { - if (this.isPopulating()) { - return; - } - - JoinTable joinTable = this.getSubject(); - if (joinTable == null) { - return; - } - - boolean selected = this.overrideDefaultJoinColumnsCheckBox.getSelection(); - this.setPopulating(true); - - try { - if (selected) { - joinTable.convertDefaultToSpecifiedJoinColumn(); - setSelectedJoinColumn(joinTable.specifiedJoinColumns().next()); - } else { - for (int index = joinTable.specifiedJoinColumnsSize(); --index >= 0; ) { - joinTable.removeSpecifiedJoinColumn(index); - } - } - } finally { - this.setPopulating(false); - } - } - - private class InverseJoinColumnsProvider implements JoinColumnsEditor<JoinTable> { - - public void addJoinColumn(JoinTable subject) { - JoinTableComposite.this.addInverseJoinColumn(subject); - } - - public JoinColumn getDefaultJoinColumn(JoinTable subject) { - return subject.getDefaultInverseJoinColumn(); - } - - public String getDefaultPropertyName() { - return JoinTable.DEFAULT_INVERSE_JOIN_COLUMN; - } - - public void editJoinColumn(JoinTable subject, JoinColumn joinColumn) { - JoinTableComposite.this.editInverseJoinColumn(joinColumn); - } - - public boolean hasSpecifiedJoinColumns(JoinTable subject) { - return subject.hasSpecifiedInverseJoinColumns(); - } - - public void removeJoinColumns(JoinTable subject, int[] selectedIndices) { - for (int index = selectedIndices.length; --index >= 0; ) { - subject.removeSpecifiedInverseJoinColumn(selectedIndices[index]); - } - } - - public ListIterator<JoinColumn> specifiedJoinColumns(JoinTable subject) { - return subject.specifiedInverseJoinColumns(); - } - - public int specifiedJoinColumnsSize(JoinTable subject) { - return subject.specifiedInverseJoinColumnsSize(); - } - - public String getSpecifiedJoinColumnsListPropertyName() { - return JoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST; - } - } - - private class JoinColumnsProvider implements JoinColumnsEditor<JoinTable> { - - public void addJoinColumn(JoinTable subject) { - JoinTableComposite.this.addJoinColumn(subject); - } - - public JoinColumn getDefaultJoinColumn(JoinTable subject) { - return subject.getDefaultJoinColumn(); - } - - public String getDefaultPropertyName() { - return JoinTable.DEFAULT_JOIN_COLUMN; - } - - public void editJoinColumn(JoinTable subject, JoinColumn joinColumn) { - JoinTableComposite.this.editJoinColumn(joinColumn); - } - - public boolean hasSpecifiedJoinColumns(JoinTable subject) { - return subject.hasSpecifiedJoinColumns(); - } - - public void removeJoinColumns(JoinTable subject, int[] selectedIndices) { - for (int index = selectedIndices.length; --index >= 0; ) { - subject.removeSpecifiedJoinColumn(selectedIndices[index]); - } - } - - public ListIterator<JoinColumn> specifiedJoinColumns(JoinTable subject) { - return subject.specifiedJoinColumns(); - } - - public int specifiedJoinColumnsSize(JoinTable subject) { - return subject.specifiedJoinColumnsSize(); - } - - public String getSpecifiedJoinColumnsListPropertyName() { - return JoinTable.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 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 JoinColumnPaneEnablerHolder - extends CachingTransformationPropertyValueModel<JoinTable, Boolean> - { - private StateChangeListener stateChangeListener; - - - public JoinColumnPaneEnablerHolder() { - super( - new ValueListAdapter<JoinTable>( - new ReadOnlyWritablePropertyValueModelWrapper(getSubjectHolder()), - JoinTable.SPECIFIED_JOIN_COLUMNS_LIST)); - this.stateChangeListener = buildStateChangeListener(); - } - - - private StateChangeListener buildStateChangeListener() { - return new StateChangeListener() { - public void stateChanged(StateChangeEvent event) { - valueStateChanged(event); - } - }; - } - - private void valueStateChanged(StateChangeEvent event) { - Object oldValue = this.cachedValue; - Object newValue = transformNew(this.valueHolder.getValue()); - firePropertyChanged(VALUE, oldValue, newValue); - } - - @Override - protected Boolean transform(JoinTable value) { - if (value == null) { - return false; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(JoinTable value) { - boolean virtual = value.getParent().getRelationshipReference().isParentVirtual(); - 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(); - } - - } - - private class InverseJoinColumnPaneEnablerHolder - extends CachingTransformationPropertyValueModel<JoinTable, Boolean> - { - private StateChangeListener stateChangeListener; - - - public InverseJoinColumnPaneEnablerHolder() { - super( - new ValueListAdapter<JoinTable>( - new ReadOnlyWritablePropertyValueModelWrapper(getSubjectHolder()), - JoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST)); - this.stateChangeListener = buildStateChangeListener(); - } - - - private StateChangeListener buildStateChangeListener() { - return new StateChangeListener() { - public void stateChanged(StateChangeEvent event) { - valueStateChanged(event); - } - }; - } - - private void valueStateChanged(StateChangeEvent event) { - Object oldValue = this.cachedValue; - Object newValue = transformNew(this.valueHolder.getValue()); - firePropertyChanged(VALUE, oldValue, newValue); - } - - @Override - protected Boolean transform(JoinTable value) { - if (value == null) { - return false; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(JoinTable value) { - boolean virtual = value.getParent().getRelationshipReference().isParentVirtual(); - 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.ui/src/org/eclipse/jpt/ui/internal/details/JoinTableJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinTableJoiningStrategyPane.java deleted file mode 100644 index 4833c1cf8a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoinTableJoiningStrategyPane.java +++ /dev/null @@ -1,115 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.context.JoinTableEnabledRelationshipReference; -import org.eclipse.jpt.core.context.JoinTableJoiningStrategy; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Join table ____________________________________________________________ | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | JoinTableComposite | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link JoinTableEnabledRelationshipReference} - * @see {@link JoinTableJoiningStrategy} - * @see {@link ManyToOneJoiningStrategyPane} - * @see {@link ManyToManyJoiningStrategyPane} - * - * @version 3.0 - * @since 2.1 - */ -public class JoinTableJoiningStrategyPane - extends AbstractJoiningStrategyPane - <JoinTableEnabledRelationshipReference, JoinTableJoiningStrategy> -{ - public JoinTableJoiningStrategyPane( - FormPane<? extends JoinTableEnabledRelationshipReference> parentPane, - Composite parent) { - super(parentPane, parent); - } - - - public JoinTableJoiningStrategyPane(FormPane<?> parentPane, - PropertyValueModel<? extends JoinTableEnabledRelationshipReference> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return new PropertyAspectAdapter<JoinTableEnabledRelationshipReference, Boolean>( - this.getSubjectHolder(), RelationshipReference.PREDOMINANT_JOINING_STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.usesJoinTableJoiningStrategy()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setJoinTableJoiningStrategy(); - } - else { - this.subject.unsetJoinTableJoiningStrategy(); - } - } - }; - } - - @Override - protected PropertyValueModel<JoinTableJoiningStrategy> buildJoiningStrategyHolder() { - return new PropertyAspectAdapter - <JoinTableEnabledRelationshipReference, JoinTableJoiningStrategy>( - getSubjectHolder()) { - @Override - protected JoinTableJoiningStrategy buildValue_() { - return this.subject.getJoinTableJoiningStrategy(); - } - }; - } - - @Override - protected String getStrategyLabelKey() { - return JptUiDetailsMessages.Joining_joinTableJoiningLabel; - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - return new JoinTableComposite(this, buildJoinTableHolder(), parent).getControl(); - } - - protected PropertyValueModel<JoinTable> buildJoinTableHolder() { - return new PropertyAspectAdapter<JoinTableJoiningStrategy, JoinTable>( - this.joiningStrategyHolder, JoinTableJoiningStrategy.JOIN_TABLE_PROPERTY) { - @Override - protected JoinTable buildValue_() { - return this.subject.getJoinTable(); - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoiningStrategyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoiningStrategyJoinColumnsComposite.java deleted file mode 100644 index e8ba71e5b3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoiningStrategyJoinColumnsComposite.java +++ /dev/null @@ -1,236 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy; -import org.eclipse.jpt.ui.internal.details.JoinColumnsComposite.JoinColumnsEditor; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.utility.internal.model.value.CachingTransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper; -import org.eclipse.jpt.utility.internal.model.value.ValueListAdapter; -import org.eclipse.jpt.utility.model.event.StateChangeEvent; -import org.eclipse.jpt.utility.model.listener.StateChangeListener; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * --------------------------------------------------------------------- - * | | - * | JoinColumnsComposite | - * | | - * --------------------------------------------------------------------- - * -------------------------------------------------------------------------</pre> - * - * @see JoinColumnEnabledRelationshipReference - * @see JoinColumnJoiningStrategy - * @see JoinColumnJoiningStrategyPane - * @see JoinColumnInJoiningStrategyDialog - * - * @version 3.0 - * @since 2.0 - */ -public class JoiningStrategyJoinColumnsComposite - extends FormPane<JoinColumnJoiningStrategy> -{ - - private JoinColumnsComposite<JoinColumnJoiningStrategy> joinColumnsComposite; - - public JoiningStrategyJoinColumnsComposite( - FormPane<?> parentPane, - PropertyValueModel<JoinColumnJoiningStrategy> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - this.joinColumnsComposite = new JoinColumnsComposite<JoinColumnJoiningStrategy>(this, container, buildJoinColumnsProvider()); - this.joinColumnsComposite.installJoinColumnsPaneEnabler(new JoinColumnPaneEnablerHolder()); - } - - private JoinColumnsEditor<JoinColumnJoiningStrategy> buildJoinColumnsProvider() { - return new JoinColumnsEditor<JoinColumnJoiningStrategy>() { - - public void addJoinColumn(JoinColumnJoiningStrategy subject) { - JoiningStrategyJoinColumnsComposite.this.addJoinColumn(subject); - } - - public boolean hasSpecifiedJoinColumns(JoinColumnJoiningStrategy subject) { - return subject.hasSpecifiedJoinColumns(); - } - - public void editJoinColumn(JoinColumnJoiningStrategy subject, JoinColumn joinColumn) { - JoiningStrategyJoinColumnsComposite.this.editJoinColumn(subject, joinColumn); - } - - public JoinColumn getDefaultJoinColumn(JoinColumnJoiningStrategy subject) { - return subject.getDefaultJoinColumn(); - } - - public String getDefaultPropertyName() { - return JoinColumnJoiningStrategy.DEFAULT_JOIN_COLUMN_PROPERTY; - } - - public String getSpecifiedJoinColumnsListPropertyName() { - return JoinColumnJoiningStrategy.SPECIFIED_JOIN_COLUMNS_LIST; - } - - public void removeJoinColumns(JoinColumnJoiningStrategy subject, int[] selectedIndices) { - for (int index = selectedIndices.length; --index >= 0; ) { - subject.removeSpecifiedJoinColumn(selectedIndices[index]); - } - } - - public ListIterator<JoinColumn> specifiedJoinColumns(JoinColumnJoiningStrategy subject) { - return subject.specifiedJoinColumns(); - } - - public int specifiedJoinColumnsSize(JoinColumnJoiningStrategy subject) { - return subject.specifiedJoinColumnsSize(); - } - }; - } - - private void addJoinColumn(JoinColumnJoiningStrategy 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()); - } - } - }; - } - - private void addJoinColumn(JoinColumnInJoiningStrategyStateObject stateObject) { - JoinColumnJoiningStrategy subject = getSubject(); - int index = subject.specifiedJoinColumnsSize(); - - JoinColumn joinColumn = subject.addSpecifiedJoinColumn(index); - stateObject.updateJoinColumn(joinColumn); - this.setSelectedJoinColumn(joinColumn); - } - - public void setSelectedJoinColumn(JoinColumn joinColumn) { - this.joinColumnsComposite.setSelectedJoinColumn(joinColumn); - } - - private void editJoinColumn(JoinColumnJoiningStrategy joiningStrategy, JoinColumn 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()); - } - } - }; - } - - private void updateJoinColumn(JoinColumnInJoiningStrategyStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - protected CachingTransformationPropertyValueModel<JoinColumnJoiningStrategy, Boolean> buildJoinColumnsPaneEnabledHolder() { - return new CachingTransformationPropertyValueModel<JoinColumnJoiningStrategy, Boolean>( - new ValueListAdapter<JoinColumnJoiningStrategy>( - new ReadOnlyWritablePropertyValueModelWrapper<JoinColumnJoiningStrategy>(getSubjectHolder()), - JoinColumnJoiningStrategy.SPECIFIED_JOIN_COLUMNS_LIST)) { - - @Override - protected Boolean transform(JoinColumnJoiningStrategy value) { - if (value == null) { - return Boolean.FALSE; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(JoinColumnJoiningStrategy value) { - boolean virtual = value.getRelationshipReference().getRelationshipMapping().getPersistentAttribute().isVirtual(); - return Boolean.valueOf(! virtual && value.specifiedJoinColumnsSize() > 0); - } - }; - - } - - - private class JoinColumnPaneEnablerHolder - extends CachingTransformationPropertyValueModel<JoinColumnJoiningStrategy, Boolean> - { - private StateChangeListener stateChangeListener; - - - public JoinColumnPaneEnablerHolder() { - super( - new ValueListAdapter<JoinColumnJoiningStrategy>( - new ReadOnlyWritablePropertyValueModelWrapper<JoinColumnJoiningStrategy>(getSubjectHolder()), - JoinColumnJoiningStrategy.SPECIFIED_JOIN_COLUMNS_LIST)); - this.stateChangeListener = buildStateChangeListener(); - } - - - private StateChangeListener buildStateChangeListener() { - return new StateChangeListener() { - public void stateChanged(StateChangeEvent event) { - valueStateChanged(event); - } - }; - } - - private void valueStateChanged(StateChangeEvent event) { - Object oldValue = this.cachedValue; - Object newValue = transformNew(this.valueHolder.getValue()); - firePropertyChanged(VALUE, oldValue, newValue); - } - - @Override - protected Boolean transform(JoinColumnJoiningStrategy value) { - if (value == null) { - return Boolean.FALSE; - } - return super.transform(value); - } - - @Override - protected Boolean transform_(JoinColumnJoiningStrategy value) { - boolean virtual = value.getRelationshipReference().isParentVirtual(); - 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.ui/src/org/eclipse/jpt/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java deleted file mode 100644 index 0295d91e18..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java +++ /dev/null @@ -1,149 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ------------------------------------------------------------------------- - * x Override Default - * --------------------------------------------------------------------- - * | | - * | JoiningStrategyJoinColumnsComposite | - * | | - * --------------------------------------------------------------------- - * -------------------------------------------------------------------------</pre> - * - * @see JoinColumnEnabledRelationshipReference - * @see JoinColumnJoiningStrategy - * @see JoinColumnJoiningStrategyPane - * @see JoinColumnInJoiningStrategyDialog - * - * @version 3.0 - * @since 2.0 - */ -public class JoiningStrategyJoinColumnsWithOverrideOptionComposite - extends FormPane<JoinColumnJoiningStrategy> -{ - - private JoiningStrategyJoinColumnsComposite joiningStrategyComposite; - - public JoiningStrategyJoinColumnsWithOverrideOptionComposite( - FormPane<?> parentPane, - PropertyValueModel<JoinColumnJoiningStrategy> 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); - } - - private void setSelectedJoinColumn(JoinColumn joinColumn) { - this.joiningStrategyComposite.setSelectedJoinColumn(joinColumn); - } - - private WritablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() { - return new OverrideDefaultJoinColumnHolder(); - } - - private ListValueModel<JoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<JoinColumnJoiningStrategy, JoinColumn>( - getSubjectHolder(), JoinColumnJoiningStrategy.SPECIFIED_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<JoinColumn> listIterator_() { - return 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 { - JoinColumnJoiningStrategy subject = getSubject(); - - // Add a join column by creating a specified one using the default - // one if it exists - if (selected) { - JoinColumn 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(0); - 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.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java deleted file mode 100644 index fa83c142bc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java +++ /dev/null @@ -1,295 +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.ui.internal.details; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali mapping panes. - * - * @version 2.0 - * @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_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 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 Boolean_False; - public static String Boolean_True; - 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 DefaultEmpty; - public static String DefaultWithOneParam; - 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 NewNameStateObject_nameAlreadyExists; - public static String NewNameStateObject_nameMustBeSpecified; - public static String NoNameSet; - public static String NoneSelected; - 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.ui/src/org/eclipse/jpt/ui/internal/details/ManyToManyJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToManyJoiningStrategyPane.java deleted file mode 100644 index 6085b30c9c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToManyJoiningStrategyPane.java +++ /dev/null @@ -1,69 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.ManyToManyMapping; -import org.eclipse.jpt.core.context.ManyToManyRelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableStrategyPane _____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToManyMapping} - * @see {@link ManyToManyRelationshipReference} - * @see {@link ManyToManyMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinTableStrategyPane} - * - * @version 2.1 - * @since 2.1 - */ -public class ManyToManyJoiningStrategyPane - extends FormPane<ManyToManyRelationshipReference> -{ - public ManyToManyJoiningStrategyPane( - FormPane<?> parentPane, - PropertyValueModel<ManyToManyRelationshipReference> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - // joining strategy group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title - ); - - new MappedByJoiningStrategyPane(this, groupPane); - - new JoinTableJoiningStrategyPane(this, groupPane); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToManyMappingComposite.java deleted file mode 100644 index 8b30fb2932..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToManyMappingComposite.java +++ /dev/null @@ -1,86 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.ManyToManyMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public class ManyToManyMappingComposite - extends AbstractManyToManyMappingComposite<ManyToManyMapping> -{ - /** - * 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 initializeLayout(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new TargetEntityComposite(this, addPane(container, groupBoxMargin)); - new ManyToManyJoiningStrategyPane(this, buildJoiningHolder(), container); - new FetchTypeComposite(this, addPane(container, groupBoxMargin)); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - new OrderingComposite(this, container); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToOneJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToOneJoiningStrategyPane.java deleted file mode 100644 index b19cc9d090..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToOneJoiningStrategyPane.java +++ /dev/null @@ -1,64 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.ManyToOneMapping; -import org.eclipse.jpt.core.context.ManyToOneRelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o JoinColumnStrategyPane ____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link ManyToOneMapping} - * @see {@link ManyToOneRelationshipReference} - * @see {@link ManyToOneMappingComposite} - * @see {@link JoinColumnStrategyPane} - * - * @version 2.1 - * @since 2.1 - */ -public class ManyToOneJoiningStrategyPane extends FormPane<ManyToOneRelationshipReference> -{ - public ManyToOneJoiningStrategyPane( - FormPane<?> parentPane, - PropertyValueModel<ManyToOneRelationshipReference> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - // joining strategy group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title - ); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox( - this, - groupPane); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToOneMappingComposite.java deleted file mode 100644 index 617cd1797b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/ManyToOneMappingComposite.java +++ /dev/null @@ -1,86 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.ManyToOneMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public class ManyToOneMappingComposite - extends AbstractManyToOneMappingComposite<ManyToOneMapping> -{ - /** - * 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 initializeLayout(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new TargetEntityComposite(this, addPane(container, groupBoxMargin)); - new ManyToOneJoiningStrategyPane(this, buildJoiningHolder(), container); - new FetchTypeComposite(this, addPane(container, groupBoxMargin)); - new OptionalComposite(this, addPane(container, groupBoxMargin)); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MapAsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MapAsComposite.java deleted file mode 100644 index 46421a499e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MapAsComposite.java +++ /dev/null @@ -1,630 +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.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.core.JpaNode; -import org.eclipse.jpt.ui.JpaPlatformUi; -import org.eclipse.jpt.ui.JptUiPlugin; -import org.eclipse.jpt.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.platform.JpaPlatformUiRegistry; -import org.eclipse.jpt.ui.internal.util.SWTUtil; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -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 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.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<?> 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); - } - - /** - * 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 { - - /** - * 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<?> 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<? extends MappingUiDefinition<?>> 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<? extends MappingUiDefinition<?>> iter = mappingChangeHandler.mappingUiDefinitions(); iter.hasNext(); ) { - MappingUiDefinition<?> mappingDefinition = iter.next(); - provider.add(mappingDefinition, itemsFilter); - } - } - finally { - monitor.done(); - } - } - - @Override - protected IDialogSettings getDialogSettings() { - - IDialogSettings dialogSettings = JptUiPlugin.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, JptUiPlugin.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.ui/src/org/eclipse/jpt/ui/internal/details/MappedByJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MappedByJoiningStrategyPane.java deleted file mode 100644 index 47f7e7c879..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MappedByJoiningStrategyPane.java +++ /dev/null @@ -1,100 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.MappedByJoiningStrategy; -import org.eclipse.jpt.core.context.OwnableRelationshipReference; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | o Mapped by _____________________________________________________________ | - * | | --------------------------------------------- ---------- | | - * | | Attribute: | | |Browse..| | | - * | | --------------------------------------------- ---------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OwnableRelationshipReference} - * @see {@link MappedByJoiningStrategy} - * @see {@link OneToOneJoiningStrategyPane} - * @see {@link OneToManyJoiningStrategyPane} - * @see {@link ManyToManyJoiningStrategyPane} - * - * @version 2.1 - * @since 2.1 - */ -public class MappedByJoiningStrategyPane - extends AbstractJoiningStrategyPane<OwnableRelationshipReference, MappedByJoiningStrategy> -{ - /** - * Creates a new <code>MappedByJoiningStrategyPane</code>. - * - * @param parentPane The parent form pane - * @param parent The parent container - */ - public MappedByJoiningStrategyPane( - FormPane<? extends OwnableRelationshipReference> parentPane, - Composite parent) { - super(parentPane, parent); - } - - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return new PropertyAspectAdapter<OwnableRelationshipReference, Boolean>( - this.getSubjectHolder(), RelationshipReference.PREDOMINANT_JOINING_STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.usesMappedByJoiningStrategy()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setMappedByJoiningStrategy(); - } - else { - this.subject.unsetMappedByJoiningStrategy(); - } - } - }; - } - - @Override - protected PropertyValueModel<MappedByJoiningStrategy> buildJoiningStrategyHolder() { - return new PropertyAspectAdapter<OwnableRelationshipReference, MappedByJoiningStrategy>( - getSubjectHolder()) { - @Override - protected MappedByJoiningStrategy buildValue_() { - return this.subject.getMappedByJoiningStrategy(); - } - }; - } - - @Override - protected String getStrategyLabelKey() { - return JptUiDetailsMessages.Joining_mappedByLabel; - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - return new MappedByPane(this, this.joiningStrategyHolder, parent).getControl(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MappedByPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MappedByPane.java deleted file mode 100644 index 22a532d56d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/MappedByPane.java +++ /dev/null @@ -1,94 +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.ui.internal.details; - -import java.util.Iterator; -import org.eclipse.jpt.core.context.MappedByJoiningStrategy; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * 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 FormPane<MappedByJoiningStrategy> -{ - /** - * Creates a new <code>MappedByPane</code>. - * - * @param parentPane The parent form pane - * @param subjectHolder The PVM for the {@link MappedByJoiningStrategy} - * @param parent The parent container - */ - public MappedByPane( - FormPane<?> parentPane, - PropertyValueModel<MappedByJoiningStrategy> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - addLabeledEditableCombo( - container, - JptUiDetailsMessages.Joining_mappedByAttributeLabel, - buildCandidateAttributesListValueModel(), - buildAttributePropertyValueModel(), - JpaHelpContextIds.MAPPING_MAPPED_BY); - } - - protected ListValueModel<String> buildCandidateAttributesListValueModel() { - return new SortedListValueModelAdapter<String>( - new CollectionAspectAdapter<MappedByJoiningStrategy, String>( - getSubjectHolder()) { - @Override - protected Iterator<String> iterator_() { - return this.subject.candidateMappedByAttributeNames(); - } - }); - } - - protected WritablePropertyValueModel<String> buildAttributePropertyValueModel() { - return new PropertyAspectAdapter<MappedByJoiningStrategy, String>( - getSubjectHolder(), MappedByJoiningStrategy.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.ui/src/org/eclipse/jpt/ui/internal/details/NamedNativeQueryPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedNativeQueryPropertyComposite.java deleted file mode 100644 index dd9899e647..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedNativeQueryPropertyComposite.java +++ /dev/null @@ -1,182 +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.ui.internal.details; - -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.NamedNativeQuery; -import org.eclipse.jpt.core.context.Query; -import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 JpaProject getJpaProject() { - return getSubject().getJpaProject(); - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java deleted file mode 100644 index bef74fcc9c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import org.eclipse.jpt.core.context.NamedQuery; -import org.eclipse.jpt.core.context.Query; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/OneToManyJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToManyJoiningStrategyPane.java deleted file mode 100644 index 9a7322b50c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToManyJoiningStrategyPane.java +++ /dev/null @@ -1,69 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.OneToManyMapping; -import org.eclipse.jpt.core.context.OneToManyRelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinTableStrategyPane _____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OneToManyMapping} - * @see {@link OneToManyRelationshipReference} - * @see {@link OneToManyMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinTableStrategyPane} - * - * @version 2.1 - * @since 2.1 - */ -public class OneToManyJoiningStrategyPane - extends FormPane<OneToManyRelationshipReference> -{ - public OneToManyJoiningStrategyPane( - FormPane<?> parentPane, - PropertyValueModel<OneToManyRelationshipReference> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - // joining strategy group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title - ); - - new MappedByJoiningStrategyPane(this, groupPane); - - new JoinTableJoiningStrategyPane(this, groupPane); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToManyMappingComposite.java deleted file mode 100644 index 2f1e4bf9ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToManyMappingComposite.java +++ /dev/null @@ -1,86 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.OneToManyMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public class OneToManyMappingComposite - extends AbstractOneToManyMappingComposite<OneToManyMapping> -{ - /** - * 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 initializeLayout(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new TargetEntityComposite(this, addPane(container, groupBoxMargin)); - new OneToManyJoiningStrategyPane(this, buildJoiningHolder(), container); - new FetchTypeComposite(this, addPane(container, groupBoxMargin)); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - new OrderingComposite(this, container); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToOneJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToOneJoiningStrategyPane.java deleted file mode 100644 index 046f04cefe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToOneJoiningStrategyPane.java +++ /dev/null @@ -1,79 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.OneToOneMapping; -import org.eclipse.jpt.core.context.OneToOneRelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * Here is the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Joining Strategy ------------------------------------------------------ | - * | | | | - * | | o MappedByJoiningStrategyPane _______________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o JoinColumnStrategyPane ____________________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | | o PrimaryKeyJoinColumnStrategyPane __________________________________ | | - * | | | | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see {@link OneToOneMapping} - * @see {@link OneToOneRelationshipReference} - * @see {@link OneToOneMappingComposite} - * @see {@link MappedByStrategyPane} - * @see {@link JoinColumnStrategyPane} - * @see {@link PrimaryKeyJoinColumnStrategyPane} - * - * @version 2.1 - * @since 2.1 - */ -public class OneToOneJoiningStrategyPane - extends FormPane<OneToOneRelationshipReference> -{ - public OneToOneJoiningStrategyPane( - FormPane<?> parentPane, - PropertyValueModel<OneToOneRelationshipReference> subjectHolder, - Composite parent) { - super(parentPane, subjectHolder, parent); - } - - - @Override - protected void initializeLayout(Composite container) { - // joining strategy group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.Joining_title - ); - - new MappedByJoiningStrategyPane(this, groupPane); - - new PrimaryKeyJoinColumnJoiningStrategyPane(this, groupPane); - - JoinColumnJoiningStrategyPane. - buildJoinColumnJoiningStrategyPaneWithIncludeOverrideCheckBox( - this, - groupPane); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToOneMappingComposite.java deleted file mode 100644 index 7ee8a3c70c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OneToOneMappingComposite.java +++ /dev/null @@ -1,86 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.OneToOneMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 1.0 - */ -public class OneToOneMappingComposite - extends AbstractOneToOneMappingComposite<OneToOneMapping> -{ - /** - * 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 initializeLayout(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new TargetEntityComposite(this, addPane(container, groupBoxMargin)); - new OneToOneJoiningStrategyPane(this, buildJoiningHolder(), container); - new FetchTypeComposite(this, addPane(container, groupBoxMargin)); - new OptionalComposite(this, addPane(container, groupBoxMargin)); - new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 5)); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OptionalComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OptionalComposite.java deleted file mode 100644 index e2f78dc225..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OptionalComposite.java +++ /dev/null @@ -1,102 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.BasicMapping; -import org.eclipse.jpt.core.context.Nullable; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<Nullable> -{ - /** - * Creates a new <code>OptionalComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public OptionalComposite(FormPane<? extends Nullable> 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<Nullable, Boolean>(getSubjectHolder(), Nullable.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() ? JptUiDetailsMessages.Boolean_True : JptUiDetailsMessages.Boolean_False; - return NLS.bind(JptUiDetailsMessages.BasicGeneralSection_optionalLabelDefault, defaultStringValue); - } - return JptUiDetailsMessages.BasicGeneralSection_optionalLabel; - } - }; - } - - - private PropertyValueModel<Boolean> buildDefaultOptionalHolder() { - return new PropertyAspectAdapter<Nullable, Boolean>( - getSubjectHolder(), - Nullable.SPECIFIED_OPTIONAL_PROPERTY, - Nullable.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.ui/src/org/eclipse/jpt/ui/internal/details/OrderingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OrderingComposite.java deleted file mode 100644 index 623ba160fd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/OrderingComposite.java +++ /dev/null @@ -1,119 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.MultiRelationshipMapping; -import org.eclipse.jpt.core.context.Orderable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Text; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | - Ordering -------------------------------------------------------------- | - * | | | | - * | | o None | | - * | | | | - * | | o Primary Key | | - * | | | | - * | | o Custom | | - * | | ------------------------------------------------------------------- | | - * | | | I | | | - * | | ------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see MultiRelationshipMapping - * @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(FormPane<? extends MultiRelationshipMapping> 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 MultiRelationshipMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - PropertyValueModel<Orderable> orderableHolder = buildOrderableHolder(); - - // Order By group - Group orderByGroup = addTitledGroup( - container, - JptUiDetailsMessages.OrderingComposite_orderingGroup, - JpaHelpContextIds.MAPPING_ORDER_BY); - - // No Ordering radio button - addRadioButton( - addSubPane(orderByGroup, 8), - JptUiDetailsMessages.OrderingComposite_none, - buildNoOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_NO_ORDERING - ); - - // Order by Primary Key radio button - addRadioButton( - orderByGroup, - JptUiDetailsMessages.OrderingComposite_primaryKey, - buildPrimaryKeyOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_PRIMARY_KEY_ORDERING - ); - - // Custom Ordering radio button - addRadioButton( - orderByGroup, - JptUiDetailsMessages.OrderingComposite_custom, - buildCustomOrderingHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY_CUSTOM_ORDERING - ); - - // Custom Ordering text field - Text customOrderingText = addUnmanagedText( - addSubPane(orderByGroup, 0, 16), - buildSpecifiedOrderByHolder(orderableHolder), - JpaHelpContextIds.MAPPING_ORDER_BY - ); - - installCustomTextEnabler(customOrderingText, orderableHolder); - } - - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java deleted file mode 100644 index 993b8f88f4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PageBookManager.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 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. - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.ui.internal.details; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.part.PageBook; - -/** - * A wrapper for a <code>PageBook</code> with convenience methods. - */ -public class PageBookManager extends PageBook { - - private Map<Object, Composite> pageRecords; - private Object active; - private PageBook pageBook; - private Composite defaultComposite; - - /** - * A <code>PageBookManager<code> is a wrapper for a <code>PageBook</code>. It provides - * convenience methods to add, remove, activate and inactive pages in the internal <code>PageBook</code>. - * If a page gets deactivated, the manager activates a default page. - * - * @param parent The parent composite to this manager - * @param aDefaultLabel The label on the the default page. - */ - public PageBookManager(Composite parent, String aDefaultLabel) { - super(parent, SWT.NULL); - this.setLayout(new FillLayout()); - this.pageRecords = new HashMap<Object, Composite>(); - this.pageBook = new PageBook(this, SWT.NONE); - this.defaultComposite = new DefaultComposite(pageBook, aDefaultLabel); - this.pageBook.showPage(this.defaultComposite); - } - - /** - * @param anObj Activates (flips to top in the <code>PageBook</code>) the associated <code>Composite</code> - * for the given <code>Object</code>. Activates the <code>DefaultComposite</code> if there is no association - * for the given <code>Object</code>. - * @return Return false if there is no <code>Composite</code> association to the given <code>Object</code> or - * the associated <code>Composite</code> is already active. - */ - public boolean activate(Object anObj) { - if(anObj != null && !anObj.equals(this.active) && this.pageRecords.containsKey(anObj)) { - Composite composite = this.pageRecords.get(anObj); - this.pageBook.showPage(composite); - this.active = anObj; - return true; - } else if((anObj == null || !anObj.equals(this.active)) && !this.pageRecords.containsKey(anObj)) { - this.pageBook.showPage(this.defaultComposite); - this.active = null; - } - return false; - } - - /** - * @param anObj - * @return Returns true if the associated <code>Composite</code> has been deactivated. - * Returns false if there is no <code>Composite</code> for the given <code>Object</code> - * or the <code>Composite</code> is already inactive. - */ - public boolean deactivate(Object anObj) { - if(anObj.equals(this.active)) { - this.pageBook.showPage(this.defaultComposite); - this.active = null; - return true; - } else { - return false; - } - } - - /** - * Associates the specified <code>Object</code> with the specified <code>Composite</code> - * in this <code>PageBookManager</code>. - * If this manager previously contained a mapping for the <code>Object</code>, the old - * <code>Composite</code> is replaced by the specified <code>Composite</code>. - * - * @param anObj <code>Object</code> with which the specified <code>Composite</code> is to be associated. - * @param aComposite <code>Composite</code> to be associated with the specified <code>Object</code>. - * - * @return previous <code>Composite</code> associated with specified <code>Object</code>, - * or <tt>null</tt> if there was no mapping for <code>Object</code>. - */ - public Composite put(Object anObj, Composite aComposite) { - Composite composite = this.pageRecords.put(anObj, aComposite); - this.activate(anObj); - return composite; - } - - /** - * Removes the mapping for this <code>Object</code> from this pagebookmanager if it is present. - * - * @param anObj <code>Object</code> whose mapping is to be removed from this <code>PageBookManager</code>. - * @return previous <code>Composite</code> associated with specified <code>Object</code>. - */ - public Composite remove(Object anObj) { - if(anObj.equals(this.active)) { - this.active = null; - this.pageBook.showPage(this.defaultComposite); - } - return this.pageRecords.remove(anObj); - } - - /** - * @param anObj whose presence in this map is to be tested - * @return true if this <code>PageBookManager</code> contains a mapping for the - * given <code>Object</code>. False otherwise. - */ - public boolean contains(Object anObj) { - return this.pageRecords.containsKey(anObj); - } - - public Composite get(Object key) { - return pageRecords.get(key); - } - - /** - * @return The currently active composite - */ - public Composite getActive() { - if(this.active == null) { - return this.defaultComposite; - } else { - return this.pageRecords.get(this.active); - } - } - - /** - * @return The internal <code>PageBook</code> of this <code>PageBookManager</code>. - * <code>Composite</code>s which should work with this manager needs to be created - * with this <code>Composite</code> as their parent composite. - */ - public Composite getComposite() { - return this.pageBook; - } - - // a default composite which is show if the active composite - // gets deactivated - private class DefaultComposite extends Composite { - public DefaultComposite(Composite aParent, String aDefaultLabel) { - super(aParent, SWT.NONE); - setLayout(new FillLayout(SWT.VERTICAL)); - Label label = new Label(this, SWT.LEFT); - label.setText(aDefaultLabel); - } - } - - @Override - public void dispose() { - super.dispose(); - for (Composite pane : this.pageRecords.values()) { - pane.dispose(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java deleted file mode 100644 index f4b953cb5e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java +++ /dev/null @@ -1,180 +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.ui.internal.details; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.Tracing; -import org.eclipse.jpt.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.model.value.FilteringPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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<T extends PersistentAttribute> extends AbstractJpaDetailsPage<T> -{ - 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<T, AttributeMapping>( - getSubjectHolder(), - PersistentAttribute.DEFAULT_MAPPING_PROPERTY, - PersistentAttribute.SPECIFIED_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.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeMapAsComposite.java deleted file mode 100644 index eac4bc20ea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeMapAsComposite.java +++ /dev/null @@ -1,139 +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.ui.internal.details; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.details.orm.UnsupportedOrmMappingUiDefinition; -import org.eclipse.jpt.ui.internal.widgets.Pane; -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<PersistentAttribute> -{ - /** - * Creates a new <code>PersistentAttributeMapAsComposite</code>. - * - * @param parentPane The parent pane of this one - * @param parent The parent container - */ - public PersistentAttributeMapAsComposite( - Pane<? extends PersistentAttribute> 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; - } - - if (getSubject().getSpecifiedMapping() == null) { - return getDefaultDefinition(getSubject().getDefaultMappingKey()).getLinkLabel(); - } - - return getMappingUiDefinition(mappingKey).getLinkLabel(); - } - - public void morphMapping(MappingUiDefinition<?> definition) { - getSubject().setSpecifiedMappingKey(definition.getKey()); - } - - public String getName() { - return getSubject().getName(); - } - - public Iterator<? extends MappingUiDefinition<?>> mappingUiDefinitions() { - return attributeMappingUiDefinitions(); - } - }; - } - - protected Iterator<? extends MappingUiDefinition<? extends AttributeMapping>> attributeMappingUiDefinitions() { - return getJpaPlatformUi().attributeMappingUiDefinitions(getSubject().getResourceType()); - } - - @Override - protected DefaultMappingUiDefinition<?> getDefaultDefinition() { - return getDefaultDefinition(getSubject().getDefaultMappingKey()); - } - - @Override - protected DefaultMappingUiDefinition<?> getDefaultDefinition(String mappingKey) { - return getJpaPlatformUi().getDefaultAttributeMappingUiDefinition(getSubject().getResourceType(), mappingKey); - } - - @Override - protected MappingUiDefinition<?> getMappingUiDefinition(String mappingKey) { - MappingUiDefinition<?> definition = super.getMappingUiDefinition(mappingKey); - if (definition != null) { - return definition; - } - return UnsupportedOrmMappingUiDefinition.instance(); - } - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(PersistentAttribute.DEFAULT_MAPPING_PROPERTY); - propertyNames.add(PersistentAttribute.SPECIFIED_MAPPING_PROPERTY); - propertyNames.add(PersistentAttribute.NAME_PROPERTY); - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - - if (propertyName == PersistentAttribute.SPECIFIED_MAPPING_PROPERTY || - propertyName == PersistentAttribute.DEFAULT_MAPPING_PROPERTY || - propertyName == PersistentAttribute.NAME_PROPERTY) { - - updateDescription(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java deleted file mode 100644 index 9bd6b98627..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.Tracing; -import org.eclipse.jpt.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.model.value.FilteringPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeMapAsComposite.java deleted file mode 100644 index af53e624e8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeMapAsComposite.java +++ /dev/null @@ -1,127 +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.ui.internal.details; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.internal.widgets.Pane; -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().getShortName(); - } - - public Iterator<? extends MappingUiDefinition<?>> 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 TypeMapping>> 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.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnDialog.java deleted file mode 100644 index 01ad531212..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnDialog.java +++ /dev/null @@ -1,108 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -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.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableDialog.java deleted file mode 100644 index 24b115eecd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableDialog.java +++ /dev/null @@ -1,111 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -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.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableStateObject.java deleted file mode 100644 index 627ba72024..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnInSecondaryTableStateObject.java +++ /dev/null @@ -1,99 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -/** - * 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.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnJoiningStrategyPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnJoiningStrategyPane.java deleted file mode 100644 index 84f5960fe8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnJoiningStrategyPane.java +++ /dev/null @@ -1,92 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumnJoiningStrategy; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 PrimaryKeyJoinColumnEnabledRelationshipReference} - * @see {@link PrimaryKeyJoinColumnJoiningStrategy} - * @see {@link OneToOneJoiningStrategyPane} - * - * @version 2.1 - * @since 2.1 - */ -public class PrimaryKeyJoinColumnJoiningStrategyPane - extends AbstractJoiningStrategyPane - <PrimaryKeyJoinColumnEnabledRelationshipReference, PrimaryKeyJoinColumnJoiningStrategy> -{ - public PrimaryKeyJoinColumnJoiningStrategyPane( - FormPane<? extends PrimaryKeyJoinColumnEnabledRelationshipReference> parentPane, - Composite parent) { - super(parentPane, parent); - } - - - @Override - protected WritablePropertyValueModel<Boolean> buildUsesStrategyHolder() { - return new PropertyAspectAdapter<PrimaryKeyJoinColumnEnabledRelationshipReference, Boolean>( - this.getSubjectHolder(), RelationshipReference.PREDOMINANT_JOINING_STRATEGY_PROPERTY) { - @Override - protected Boolean buildValue() { - return (this.subject == null) ? Boolean.FALSE : - Boolean.valueOf(this.subject.usesPrimaryKeyJoinColumnJoiningStrategy()); - } - - @Override - protected void setValue_(Boolean value) { - if (value == Boolean.TRUE) { - this.subject.setPrimaryKeyJoinColumnJoiningStrategy(); - } - else { - this.subject.unsetPrimaryKeyJoinColumnJoiningStrategy(); - } - } - }; - } - - @Override - protected PropertyValueModel<PrimaryKeyJoinColumnJoiningStrategy> buildJoiningStrategyHolder() { - return new PropertyAspectAdapter - <PrimaryKeyJoinColumnEnabledRelationshipReference, PrimaryKeyJoinColumnJoiningStrategy>( - getSubjectHolder()) { - @Override - protected PrimaryKeyJoinColumnJoiningStrategy buildValue_() { - return this.subject.getPrimaryKeyJoinColumnJoiningStrategy(); - } - }; - } - - @Override - protected String getStrategyLabelKey() { - return JptUiDetailsMessages.Joining_primaryKeyJoinColumnJoiningLabel; - } - - @Override - protected Composite buildStrategyDetailsComposite(Composite parent) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnStateObject.java deleted file mode 100644 index 815ccfa4ae..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnStateObject.java +++ /dev/null @@ -1,101 +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.ui.internal.details; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -/** - * 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.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java deleted file mode 100644 index a7bab8d6cc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java +++ /dev/null @@ -1,423 +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.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.core.context.BaseJoinColumn; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.PostExecution; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.osgi.util.NLS; -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> - * ----------------------------------------------------------------------------- - * | - Join Columns ---------------------------------------------------------- | - * | | | | - * | | x Override Default | | - * | | | | - * | | --------------------------------------------------------------------- | | - * | | | | | | - * | | | AddRemoveListPane | | | - * | | | | | | - * | | --------------------------------------------------------------------- | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see SecondaryTable - * @see EntityComposite - The container of this pane - * @see AddRemoveListPane - * - * @version 2.0 - * @since 1.0 - */ -public class PrimaryKeyJoinColumnsInSecondaryTableComposite extends FormPane<SecondaryTable> -{ - private WritablePropertyValueModel<PrimaryKeyJoinColumn> 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(FormPane<?> parentPane, - PropertyValueModel<? extends SecondaryTable> 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 SecondaryTable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - private void addJoinColumn(PrimaryKeyJoinColumnInSecondaryTableStateObject stateObject) { - - SecondaryTable secondaryTable = stateObject.getOwner(); - int index = secondaryTable.specifiedPrimaryKeyJoinColumnsSize(); - - PrimaryKeyJoinColumn joinColumn = secondaryTable.addSpecifiedPrimaryKeyJoinColumn(index); - stateObject.updateJoinColumn(joinColumn); - } - - private void addPrimaryKeyJoinColumn() { - - PrimaryKeyJoinColumnInSecondaryTableDialog dialog = - new PrimaryKeyJoinColumnInSecondaryTableDialog(getShell(), 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<SecondaryTable, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform(SecondaryTable value) { - if (value == null) { - return Boolean.FALSE; - } - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - private PropertyValueModel<PrimaryKeyJoinColumn> buildDefaultJoinColumnHolder() { - return new PropertyAspectAdapter<SecondaryTable, PrimaryKeyJoinColumn>(getSubjectHolder(), SecondaryTable.DEFAULT_PRIMARY_KEY_JOIN_COLUMN) { - @Override - protected PrimaryKeyJoinColumn buildValue_() { - return subject.getDefaultPrimaryKeyJoinColumn(); - } - }; - } - - private ListValueModel<PrimaryKeyJoinColumn> buildDefaultJoinColumnListHolder() { - return new PropertyListValueModelAdapter<PrimaryKeyJoinColumn>( - buildDefaultJoinColumnHolder() - ); - } - - private PostExecution<PrimaryKeyJoinColumnInSecondaryTableDialog> buildEditPrimaryKeyJoinColumnPostExecution() { - return new PostExecution<PrimaryKeyJoinColumnInSecondaryTableDialog>() { - public void execute(PrimaryKeyJoinColumnInSecondaryTableDialog dialog) { - if (dialog.wasConfirmed()) { - editPrimaryKeyJoinColumn(dialog.getSubject()); - } - } - }; - } - - private String buildJoinColumnLabel(PrimaryKeyJoinColumn joinColumn) { - - if (joinColumn.isVirtual()) { - 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) { - PrimaryKeyJoinColumn joinColumn = (PrimaryKeyJoinColumn) 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<PrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnHolder() { - return new SimplePropertyValueModel<PrimaryKeyJoinColumn>(); - } - - private ListValueModel<PrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListHolder() { - List<ListValueModel<PrimaryKeyJoinColumn>> list = new ArrayList<ListValueModel<PrimaryKeyJoinColumn>>(); - list.add(buildSpecifiedJoinColumnsListHolder()); - list.add(buildDefaultJoinColumnListHolder()); - return new CompositeListValueModel<ListValueModel<PrimaryKeyJoinColumn>, PrimaryKeyJoinColumn>(list); - } - - private ListValueModel<PrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListModel() { - return new ItemPropertyListValueModelAdapter<PrimaryKeyJoinColumn>( - buildPrimaryKeyJoinColumnsListHolder(), - NamedColumn.SPECIFIED_NAME_PROPERTY, - NamedColumn.DEFAULT_NAME_PROPERTY, - BaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, - BaseJoinColumn.DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY - ); - } - - private ListValueModel<PrimaryKeyJoinColumn> buildSpecifiedJoinColumnsListHolder() { - return new ListAspectAdapter<SecondaryTable, PrimaryKeyJoinColumn>(getSubjectHolder(), SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST) { - @Override - protected ListIterator<PrimaryKeyJoinColumn> listIterator_() { - return subject.specifiedPrimaryKeyJoinColumns(); - } - - @Override - protected int size_() { - return subject.specifiedPrimaryKeyJoinColumnsSize(); - } - }; - } - - private void editPrimaryKeyJoinColumn(ObjectListSelectionModel listSelectionModel) { - - PrimaryKeyJoinColumn joinColumn = (PrimaryKeyJoinColumn) listSelectionModel.selectedValue(); - - PrimaryKeyJoinColumnInSecondaryTableDialog dialog = - new PrimaryKeyJoinColumnInSecondaryTableDialog( - getShell(), - getSubject(), - joinColumn - ); - - dialog.openDialog(buildEditPrimaryKeyJoinColumnPostExecution()); - } - - private void editPrimaryKeyJoinColumn(PrimaryKeyJoinColumnInSecondaryTableStateObject stateObject) { - stateObject.updateJoinColumn(stateObject.getJoinColumn()); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initialize() { - super.initialize(); - joinColumnHolder = buildPrimaryKeyJoinColumnHolder(); - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Primary Key Join Columns group pane - Group groupPane = addTitledGroup( - container, - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_primaryKeyJoinColumn - ); - - // Override Default check box - Button button = addCheckBox( - addSubPane(groupPane, 8), - JptUiDetailsMessages.PrimaryKeyJoinColumnsComposite_overrideDefaultPrimaryKeyJoinColumns, - buildOverrideDefaultJoinColumnHolder(), - null - ); - - installOverrideDefaultButtonEnabler(button); - - // Primary Key Join Columns list pane - AddRemoveListPane<SecondaryTable> joinColumnsPane = new AddRemoveListPane<SecondaryTable>( - this, - groupPane, - buildPrimaryKeyJoinColumnAdapter(), - buildPrimaryKeyJoinColumnsListModel(), - joinColumnHolder, - buildJoinColumnsListLabelProvider(), - JpaHelpContextIds.MAPPING_JOIN_TABLE_COLUMNS - ); - - installPrimaryKeyJoinColumnListPaneEnabler(joinColumnsPane); - } - - private void installOverrideDefaultButtonEnabler(Button overrideDefaultButton) { - SWTTools.controlEnabledState(buildControlBooleanHolder(), overrideDefaultButton); - } - - private void installPrimaryKeyJoinColumnListPaneEnabler(AddRemoveListPane<SecondaryTable> pkJoinColumnListPane) { - - new PaneEnabler( - buildOverrideDefaultJoinColumnHolder(), - pkJoinColumnListPane - ); - } - - private void removePrimaryKeyJoinColumn(ObjectListSelectionModel listSelectionModel) { - int[] selectedIndices = listSelectionModel.selectedIndices(); - - for (int index = selectedIndices.length; --index >= 0; ) { - getSubject().removeSpecifiedPrimaryKeyJoinColumn(selectedIndices[index]); - } - } - - private void updateJoinColumns(boolean selected) { - - if (isPopulating()) { - return; - } - - setPopulating(true); - - try { - 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() { - if (getSubject() == null) { - return Boolean.FALSE; - } - return !getSubject().isVirtual() && listHolder.size() > 0; - } - - public void setValue(Boolean value) { - updateJoinColumns(value); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java deleted file mode 100644 index e741243831..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java +++ /dev/null @@ -1,313 +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.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.core.context.NamedNativeQuery; -import org.eclipse.jpt.core.context.NamedQuery; -import org.eclipse.jpt.core.context.Query; -import org.eclipse.jpt.core.context.QueryContainer; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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; - private NamedNativeQueryPropertyComposite namedNativeQueryPane; - private NamedQueryPropertyComposite<? extends NamedQuery> namedQueryPane; - private WritablePropertyValueModel<Query> queryHolder; - - - public QueriesComposite( - Pane<?> parentPane, - PropertyValueModel<? extends QueryContainer> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent, false); - } - - private void addQuery() { - addQueryFromDialog(buildAddQueryDialog()); - } - - protected AddQueryDialog buildAddQueryDialog() { - return new AddQueryDialog(getControl().getShell()); - } - - protected void addQueryFromDialog(AddQueryDialog dialog) { - if (dialog.open() != Window.OK) { - return; - } - String queryType = dialog.getQueryType(); - Query query; - if (queryType == Query.NAMED_QUERY) { - query = this.getSubject().addNamedQuery(getSubject().namedQueriesSize()); - } - else if (queryType == Query.NAMED_NATIVE_QUERY) { - query = this.getSubject().addNamedNativeQuery(getSubject().namedNativeQueriesSize()); - } - 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, 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.ui/src/org/eclipse/jpt/ui/internal/details/QueryHintsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueryHintsComposite.java deleted file mode 100644 index 8c668bac03..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueryHintsComposite.java +++ /dev/null @@ -1,339 +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.ui.internal.details; - -import java.util.ListIterator; -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.core.context.NamedQuery; -import org.eclipse.jpt.core.context.Query; -import org.eclipse.jpt.core.context.QueryHint; -import org.eclipse.jpt.ui.internal.swt.ColumnAdapter; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveTablePane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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().hintsSize()); - 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 ListIterator<QueryHint> listIterator_() { - return subject.hints(); - } - - @Override - protected int size_() { - return subject.hintsSize(); - } - }; - } - - /* - * (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.ui/src/org/eclipse/jpt/ui/internal/details/SecondaryTableDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/SecondaryTableDialog.java deleted file mode 100644 index 5d39fa0e00..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/SecondaryTableDialog.java +++ /dev/null @@ -1,451 +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.ui.internal.details; - -import java.util.Iterator; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.db.Database; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.utility.internal.StringTools; -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 (Iterator<String> stream = database.sortedCatalogIdentifiers(); stream.hasNext(); ) { - this.catalogCombo.add(stream.next()); - } - } - } - - 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 (Iterator<String> stream = sc.sortedSchemaIdentifiers(); stream.hasNext(); ) { - this.schemaCombo.add(stream.next()); - } - } - } - - 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 (Iterator<String> stream = dbSchema.sortedTableIdentifiers(); stream.hasNext(); ) { - this.tableCombo.add(stream.next()); - } - } - } - - - // ********** 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.ui/src/org/eclipse/jpt/ui/internal/details/SequenceGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/SequenceGeneratorComposite.java deleted file mode 100644 index 7879e9721f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.GeneratorContainer; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.core.context.SequenceGenerator; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.SequenceCombo; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/TableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TableComposite.java deleted file mode 100644 index 22d983e2fc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TableComposite.java +++ /dev/null @@ -1,238 +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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.ui.internal.details.db.TableCombo; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<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(FormPane<? 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.ui/src/org/eclipse/jpt/ui/internal/details/TableGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TableGeneratorComposite.java deleted file mode 100644 index 1a33eb97c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.GeneratorContainer; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.core.context.TableGenerator; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.ui.internal.details.db.ColumnCombo; -import org.eclipse.jpt.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.ui.internal.details.db.TableCombo; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/TargetEntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TargetEntityComposite.java deleted file mode 100644 index f84c660df5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TargetEntityComposite.java +++ /dev/null @@ -1,397 +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.ui.internal.details; - -import java.util.Collection; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -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.fieldassist.FieldDecorationRegistry; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.ui.JptUiPlugin; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.util.SWTUtil; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -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.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.ui.forms.widgets.Hyperlink; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | -------------------------------------------- ------------- | - * | Target Entity: | I |v| | Browse... | | - * | -------------------------------------------- ------------- | - * -----------------------------------------------------------------------------</pre> - * - * @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 - */ -@SuppressWarnings("nls") -public class TargetEntityComposite extends FormPane<RelationshipMapping> -{ - private JavaTypeCompletionProcessor javaTypeCompletionProcessor; - - private Combo combo; - - /** - * Creates a new <code>TargetEntityComposite</code>. - * - * @param parentPane The parent container of this one - * @param parent The parent container - */ - public TargetEntityComposite(FormPane<? extends RelationshipMapping> parentPane, - Composite parent) { - - super(parentPane, parent); - } - - /** - * Creates a new <code>TargetEntityComposite</code>. - * - * @param subjectHolder The holder of the subject <code>IRelationshipMapping</code> - * @param parent The parent container - * @param widgetFactory The factory used to create various common widgets - */ - public TargetEntityComposite(PropertyValueModel<? extends RelationshipMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void addPropertyNames(Collection<String> propertyNames) { - super.addPropertyNames(propertyNames); - propertyNames.add(RelationshipMapping.DEFAULT_TARGET_ENTITY_PROPERTY); - propertyNames.add(RelationshipMapping.SPECIFIED_TARGET_ENTITY_PROPERTY); - } - @Override - protected void initialize() { - super.initialize(); - - // TODO bug 156185 - when this is fixed there should be api for this - this.javaTypeCompletionProcessor = new JavaTypeCompletionProcessor(false, false); - } - - @Override - protected void initializeLayout(Composite container) { - Composite comboPane = addSubPane(container); - this.combo = addEditableCombo(comboPane); - this.combo.add(JptUiDetailsMessages.DefaultEmpty); - this.combo.addModifyListener(buildTargetEntityModifyListener()); - - Image image = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage(); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = image.getBounds().width; - this.combo.setLayoutData(data); - - ControlContentAssistHelper.createComboContentAssistant( - this.combo, - javaTypeCompletionProcessor - ); - - - - SWTUtil.attachDefaultValueHandler(this.combo); - - Hyperlink labelLink = addHyperlink(container, - JptUiDetailsMessages.TargetEntityChooser_label, - buildOpenTargetEntityAction() - ); - - addLabeledComposite( - container, - labelLink, - comboPane, - addTargetEntitySelectionButton(container), - JpaHelpContextIds.MAPPING_TARGET_ENTITY - ); - } - - private void openEditor() { - - String targetEntity = getSubject().getTargetEntity(); - - if (targetEntity != null) { - - try { - IType type = getSubject().getJpaProject().getJavaProject().findType(targetEntity.replace('$', '.')); - - if (type != null) { - IJavaElement javaElement = type.getParent(); - JavaUI.openInEditor(javaElement, true, true); - } - } - catch (JavaModelException e) { - JptUiPlugin.log(e); - } - catch (PartInitException e) { - JptUiPlugin.log(e); - } - } - } - private Runnable buildOpenTargetEntityAction() { - return new Runnable() { - public void run() { - TargetEntityComposite.this.openEditor(); - } - }; - } - - private Runnable buildOpenTypeAction() { - return new Runnable() { - public void run() { - BusyIndicator.showWhile(combo.getDisplay(), new Runnable() { - public void run() { - doOpenSelectionDialog(); - } - }); - } - }; - } - - private ModifyListener buildTargetEntityModifyListener() { - return new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (!isPopulating()) { - Combo combo = (Combo) e.widget; - valueChanged(combo.getText()); - } - } - }; - } - - private Button addTargetEntitySelectionButton(Composite parent) { - return addPushButton( - parent, - JptUiDetailsMessages.TargetEntityChooser_browse, - buildOpenTypeAction() - ); - } - - private void doOpenSelectionDialog() { - SelectionDialog dialog; - - try { - dialog = JavaUI.createTypeDialog( - getControl().getShell(), - PlatformUI.getWorkbench().getProgressService(), - SearchEngine.createWorkspaceScope(), - IJavaElementSearchConstants.CONSIDER_ALL_TYPES, - false - ); - } - catch (JavaModelException e) { - JptUiPlugin.log(e); - return; - } - - dialog.setTitle(JptUiDetailsMessages.TargetEntityChooser_selectTypeTitle); - - if (dialog.open() == Window.OK) { - IType type = (IType) dialog.getResult()[0]; - this.combo.setText(type.getFullyQualifiedName(getSubject().getTargetEntityEnclosingTypeSeparator())); - } - } - - @Override - protected void doPopulate() { - - super.doPopulate(); - populateCombo(); - updatePackageFragment(); - } - - private void updatePackageFragment() { - - if (getSubject() != null) { - IPackageFragmentRoot root = getPackageFragmentRoot(); - - if (root != null) { - javaTypeCompletionProcessor.setPackageFragment(root.getPackageFragment("")); - return; - } - } - - javaTypeCompletionProcessor.setPackageFragment(null); - } - - /** - * Retrieves the ?? - * - * @return Either the root of the package fragment or <code>null</code> if it - * can't be retrieved - */ - protected IPackageFragmentRoot getPackageFragmentRoot() { - IProject project = getSubject().getJpaProject().getProject(); - IJavaProject root = JavaCore.create(project); - - try { - return root.getAllPackageFragmentRoots()[0]; - } - catch (JavaModelException e) { - JptUiPlugin.log(e); - } - return null; - } - - - - private void populateCombo() { - - combo.removeAll(); - populateDefaultValue(); - // TODO Add possible target entity names - updateSelectedItem(); - } - - /** - * Adds the default value to the combo if one exists. - */ - private void populateDefaultValue() { - - RelationshipMapping entity = getSubject(); - String defaultValue = (entity != null) ? entity.getDefaultTargetEntity() : null; - - if (defaultValue != null) { - combo.add(NLS.bind( - JptUiDetailsMessages.DefaultWithOneParam, - defaultValue - )); - } - else { - combo.add(JptUiDetailsMessages.DefaultEmpty); - } - } - - /* - * (non-Javadoc) - */ - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - - if (propertyName == RelationshipMapping.DEFAULT_TARGET_ENTITY_PROPERTY || - propertyName == RelationshipMapping.SPECIFIED_TARGET_ENTITY_PROPERTY) { - - populateCombo(); - } - } - - /** - * Updates the selected item by selected the current value, if not - * <code>null</code>, or select the default value if one is available, - * otherwise remove the selection. - * <p> - * <b>Note:</b> It seems the text can be shown as truncated, changing the - * selection to (0, 0) makes the entire text visible. - */ - private void updateSelectedItem() { - RelationshipMapping subject = getSubject(); - String value = (subject != null) ? subject.getSpecifiedTargetEntity() : null; - - if (value != null) { - combo.setText(value); - combo.setSelection(new Point(0, 0)); - } - else { - String defaultValue = (subject != null) ? subject.getDefaultTargetEntity() : null; - String displayString = JptUiDetailsMessages.DefaultEmpty; - - if (defaultValue != null) { - displayString = NLS.bind( - JptUiDetailsMessages.DefaultWithOneParam, - defaultValue - ); - } - - // Selected the default value - if (displayString != null) { - combo.select(0); - combo.setSelection(new Point(0, 0)); - } - // Remove the selection - else { - combo.select(-1); - } - } - } - - private void valueChanged(String value) { - - RelationshipMapping subject = getSubject(); - String oldValue = (subject != null) ? subject.getSpecifiedTargetEntity() : null; - - // Check for null value - if (StringTools.stringIsEmpty(value)) { - value = null; - - if (StringTools.stringIsEmpty(oldValue)) { - return; - } - } - - // The default value - if (value != null && - combo.getItemCount() > 0 && - value.equals(combo.getItem(0))) - { - value = null; - } - - // Nothing to change - if ((oldValue == value) && value == null) { - return; - } - - // Set the new value - if ((value != null) && (oldValue == null) || - ((oldValue != null) && !oldValue.equals(value))) { - - setPopulating(true); - - try { - subject.setSpecifiedTargetEntity(value); - } - finally { - setPopulating(false); - } - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TemporalTypeComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TemporalTypeComposite.java deleted file mode 100644 index 39498e7309..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TemporalTypeComposite.java +++ /dev/null @@ -1,139 +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.ui.internal.details; - -import java.util.Comparator; -import java.util.List; -import org.eclipse.jpt.core.context.TemporalConverter; -import org.eclipse.jpt.core.context.TemporalType; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.util.SWTUtil; -import org.eclipse.jpt.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringConverter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.custom.CCombo; -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 FormPane<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) { - - CCombo combo = addCCombo( - container, - buildTemporalTypeListHolder(), - buildTemporalTypeHolder(), - buildTemporalTypeConverter() - ); - - SWTTools.controlEnabledState(buildBooleanHolder(), combo); - } - - 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.ui/src/org/eclipse/jpt/ui/internal/details/TransientMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TransientMappingComposite.java deleted file mode 100644 index 919dcb4e78..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/TransientMappingComposite.java +++ /dev/null @@ -1,50 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.TransientMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 FormPane<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.ui/src/org/eclipse/jpt/ui/internal/details/VersionMappingComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/VersionMappingComposite.java deleted file mode 100644 index 129bc307de..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/VersionMappingComposite.java +++ /dev/null @@ -1,66 +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.ui.internal.details; - -import org.eclipse.jpt.core.context.VersionMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | ColumnComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | TemporalTypeComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see VersionMapping - * @see ColumnComposite - * @see TemporalTypeComposite - * - * @version 2.0 - * @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 initializeLayout(Composite container) { - - // Column widgets - new ColumnComposite(this, buildColumnHolder(), container); - - initializeConversionPane(container); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/CatalogCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/CatalogCombo.java deleted file mode 100644 index 326f43e4eb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/CatalogCombo.java +++ /dev/null @@ -1,53 +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.ui.internal.details.db; - -import java.util.Iterator; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.db.Database; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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); - } - - public CatalogCombo( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory - ) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected Iterator<String> values() { - Database db = this.getDatabase(); - return (db != null) ? db.sortedCatalogIdentifiers() : EmptyIterator.<String>instance(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/ColumnCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/ColumnCombo.java deleted file mode 100644 index 3de126f124..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/ColumnCombo.java +++ /dev/null @@ -1,70 +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.ui.internal.details.db; - -import java.util.Iterator; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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); - } - - public ColumnCombo( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory - ) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected Iterator<String> values() { - Table dbTable = this.getDbTable(); - return (dbTable != null) ? dbTable.sortedColumnIdentifiers() : EmptyIterator.<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.ui/src/org/eclipse/jpt/ui/internal/details/db/DatabaseObjectCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/DatabaseObjectCombo.java deleted file mode 100644 index af6aad8b2c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/DatabaseObjectCombo.java +++ /dev/null @@ -1,579 +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.ui.internal.details.db; - -import java.util.Iterator; -import org.eclipse.jpt.core.JpaDataSource; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.db.Catalog; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.ConnectionListener; -import org.eclipse.jpt.db.ConnectionProfile; -import org.eclipse.jpt.db.Database; -import org.eclipse.jpt.db.ForeignKey; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Sequence; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.Tracing; -import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.ui.internal.listeners.SWTConnectionListenerWrapper; -import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper; -import org.eclipse.jpt.ui.internal.util.SWTUtil; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -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 Pane<T> -{ - - /** - * The main (only) widget of this pane. - */ - private CCombo comboBox; - - /** - * 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); - } - - protected DatabaseObjectCombo( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory - ) { - super(subjectHolder, parent, widgetFactory); - } - - - // ********** 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(); - } - - @Override - protected void initializeLayout(Composite container) { - this.comboBox = this.addEditableCCombo(container); - this.comboBox.addModifyListener(this.buildModifyListener()); - SWTUtil.attachDefaultValueHandler(this.comboBox); - } - - protected ModifyListener buildModifyListener() { - return new ModifyListener() { - public void modifyText(ModifyEvent e) { - DatabaseObjectCombo.this.comboBoxModified(); - } - }; - } - - - // ********** abstract methods ********** - - /** - * Return the possible values to be added to the combo during - * population. - */ - protected abstract Iterator<String> values(); - - /** - * Return the default value, or <code>null</code> if no default is - * specified. This method is only called when the subject is non-null. - */ - protected abstract String getDefaultValue(); - - /** - * Return the current value from the subject. - * This method is only called when the subject is non-null. - */ - protected abstract String getValue(); - - /** - * Set the specified value as the new value on the subject. - */ - protected abstract void setValue(String value); - - - // ********** 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 - public void enableWidgets(boolean enabled) { - super.enableWidgets(enabled); - - if ( ! this.comboBox.isDisposed()) { - this.comboBox.setEnabled(enabled); - } - } - - @Override - protected void propertyChanged(String propertyName) { - super.propertyChanged(propertyName); - this.updateSelectedItem(); - } - - @Override - protected void doPopulate() { - super.doPopulate(); - this.populateComboBox(); - } - - - // ********** populating ********** - - /** - * Populate the combo-box list by clearing it, then adding first the default - * value, if available, and then the possible choices. - */ - protected void populateComboBox() { - this.comboBox.removeAll(); - - this.comboBox.add(this.buildDefaultValueEntry()); - - if (this.connectionProfileIsActive()) { - for (Iterator<String> stream = this.values(); stream.hasNext(); ) { - this.comboBox.add(stream.next()); - } - } - - this.updateSelectedItem_(); - } - - protected String buildDefaultValueEntry() { - if (getSubject() == null) { - return JptUiDetailsMessages.NoneSelected; - } - String defaultValue = this.getDefaultValue(); - return (defaultValue == null) ? this.buildNullDefaultValueEntry() : this.buildNonNullDefaultValueEntry(defaultValue); - } - - protected String buildNullDefaultValueEntry() { - return JptUiDetailsMessages.DefaultEmpty; - } - - protected String buildNonNullDefaultValueEntry(String defaultValue) { - return NLS.bind( - JptUiDetailsMessages.DefaultWithOneParam, - defaultValue - ); - } - - protected void updateSelectedItem() { - // make sure the default value is up to date (??? ~bjv) - String defaultValueEntry = this.buildDefaultValueEntry(); - if ( ! this.comboBox.getItem(0).equals(defaultValueEntry)) { - this.comboBox.remove(0); - this.comboBox.add(defaultValueEntry, 0); - } - - this.updateSelectedItem_(); - } - - /** - * Updates the selected item by selecting the current value, if not - * <code>null</code>, or select the default value if one is available, - * otherwise remove the selection. - */ - protected void updateSelectedItem_() { - String value = (this.getSubject() == null) ? null : this.getValue(); - if (value == null) { - // select the default value - this.comboBox.select(0); - } else { - // select the new value - if ( ! value.equals(this.comboBox.getText())) { - // This prevents the cursor from being set back to the beginning of the line (bug 234418). - // The reason we are hitting this method at all is because the - // context model is updating from the resource model in a way - // that causes change notifications to be fired (the annotation - // is added to the resource model, change notification occurs - // on the update thread, and then the name is set, these 2 - // threads can get in the wrong order). - // The #valueChanged() method sets the populating flag to true, - // but in this case it is already set back to false when we - // receive notification back from the model because it has - // moved to the update thread and then jumps back on the UI thread. - this.comboBox.setText(value); - } - } - } - - - // ********** combo-box listener callback ********** - - protected void comboBoxModified() { - if ( ! this.isPopulating()) { - this.valueChanged(this.comboBox.getText()); - } - } - - /** - * The combo-box selection has changed, update the model if necessary. - * If the value has changed and the subject is null, we can build a subject - * before setting the value. - */ - protected void valueChanged(String newValue) { - JpaNode subject = this.getSubject(); - String oldValue; - if (subject == null) { - if (this.nullSubjectIsNotAllowed()) { - return; // no subject to set the value on - } - oldValue = null; - } else { - oldValue = this.getValue(); - } - - // convert empty string or default to null - if (StringTools.stringIsEmpty(newValue) || this.valueIsDefault(newValue)) { - newValue = null; - } - - // set the new value if it is different from the old value - if (this.valuesAreDifferent(oldValue, newValue)) { - this.setPopulating(true); - - try { - this.setValue(newValue); - } finally { - this.setPopulating(false); - } - } - } - - /** - * Return whether we can set the value when the subject is null - * (i.e. #setValue(String) will construct the subject if necessary). - */ - protected boolean nullSubjectIsAllowed() { - return false; - } - - protected final boolean nullSubjectIsNotAllowed() { - return ! this.nullSubjectIsAllowed(); - } - - /** - * pre-condition: value is not null - */ - protected boolean valueIsDefault(String value) { - return (this.comboBox.getItemCount() > 0) - && value.equals(this.comboBox.getItem(0)); - } - - protected boolean valuesAreEqual(String value1, String value2) { - if ((value1 == null) && (value2 == null)) { - return true; // both are null - } - if ((value1 == null) || (value2 == null)) { - return false; // one is null but the other is not - } - return value1.equals(value2); - } - - protected boolean valuesAreDifferent(String value1, String value2) { - return ! this.valuesAreEqual(value1, value2); - } - - - // ********** 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 void repopulateComboBox() { - if ( ! this.comboBox.isDisposed()) { - this.repopulate(); - } - } - - 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); - } - } - - - // ********** 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.ui/src/org/eclipse/jpt/ui/internal/details/db/SchemaCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/SchemaCombo.java deleted file mode 100644 index 6a1dbcdf15..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/SchemaCombo.java +++ /dev/null @@ -1,62 +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.ui.internal.details.db; - -import java.util.Iterator; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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); - } - - public SchemaCombo( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory - ) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected Iterator<String> values() { - SchemaContainer sc = this.getDbSchemaContainer(); - return (sc != null) ? sc.sortedSchemaIdentifiers() : EmptyIterator.<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.ui/src/org/eclipse/jpt/ui/internal/details/db/SequenceCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/SequenceCombo.java deleted file mode 100644 index 30ceaf146a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/SequenceCombo.java +++ /dev/null @@ -1,62 +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.ui.internal.details.db; - -import java.util.Iterator; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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<? extends T> parentPane, Composite parent) { - super(parentPane, parent); - } - - public SequenceCombo( - Pane<?> parentPane, - PropertyValueModel<? extends T> subjectHolder, - Composite parent - ) { - super(parentPane, subjectHolder, parent); - } - - public SequenceCombo( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory - ) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected Iterator<String> values() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema != null) ? dbSchema.sortedSequenceIdentifiers() : EmptyIterator.<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.ui/src/org/eclipse/jpt/ui/internal/details/db/TableCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/TableCombo.java deleted file mode 100644 index 5d7542124f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/db/TableCombo.java +++ /dev/null @@ -1,62 +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.ui.internal.details.db; - -import java.util.Iterator; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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); - } - - public TableCombo( - PropertyValueModel<? extends T> subjectHolder, - Composite parent, - WidgetFactory widgetFactory - ) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected Iterator<String> values() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema != null) ? dbSchema.sortedTableIdentifiers() : EmptyIterator.<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.ui/src/org/eclipse/jpt/ui/internal/details/java/AbstractJavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/AbstractJavaResourceUiDefinition.java deleted file mode 100644 index 9670d4e0ca..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/AbstractJavaResourceUiDefinition.java +++ /dev/null @@ -1,221 +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.ui.internal.details.java; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.MappingResourceUiDefinition; -import org.eclipse.jpt.ui.ResourceUiDefinition; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.DefaultJavaTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.structure.JavaResourceModelStructureProvider; -import org.eclipse.jpt.ui.structure.JpaStructureProvider; -import org.eclipse.jpt.utility.internal.Tools; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.utility.internal.iterators.ArrayListIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 ResourceUiDefinition, 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(JpaResourceType resourceType) { - return resourceType.equals(JptCorePlugin.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 : getSpecifiedTypeMappingUiDefintions()) { - if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) { - return definition; - } - } - throw new IllegalArgumentException("Illegal type mapping key: " + mappingKey); //$NON-NLS-1$ - } - - public Iterator<MappingUiDefinition<? extends TypeMapping>> typeMappingUiDefinitions() { - return new ArrayIterator<MappingUiDefinition<? extends TypeMapping>>(getSpecifiedTypeMappingUiDefintions()); - } - - protected synchronized JavaTypeMappingUiDefinition<? extends TypeMapping>[] getSpecifiedTypeMappingUiDefintions() { - if (this.specifiedTypeMappingUiDefinitions == null) { - this.specifiedTypeMappingUiDefinitions = this.buildSpecifiedTypeMappingUiDefintions(); - } - 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>[] buildSpecifiedTypeMappingUiDefintions() { - ArrayList<JavaTypeMappingUiDefinition<? extends TypeMapping>> definitions = new ArrayList<JavaTypeMappingUiDefinition<? extends TypeMapping>>(); - this.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<? extends AttributeMapping>> attributeMappingUiDefinitions() { - return new ArrayListIterator<MappingUiDefinition<? extends AttributeMapping>>(getSpecifiedAttributeMappingUiDefinitions()); - } - - protected synchronized JavaAttributeMappingUiDefinition<? extends AttributeMapping>[] getSpecifiedAttributeMappingUiDefinitions() { - if (this.specifiedAttributeMappingUiDefinitions == null) { - this.specifiedAttributeMappingUiDefinitions = this.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>>(); - this.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<?>>(); - this.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.ui/src/org/eclipse/jpt/ui/internal/details/java/BaseJavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/BaseJavaUiFactory.java deleted file mode 100644 index 85a9ee321f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/BaseJavaUiFactory.java +++ /dev/null @@ -1,174 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.core.context.java.JavaEntity; -import org.eclipse.jpt.core.context.java.JavaIdMapping; -import org.eclipse.jpt.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.BasicMappingComposite; -import org.eclipse.jpt.ui.internal.details.EmbeddableComposite; -import org.eclipse.jpt.ui.internal.details.EmbeddedIdMappingComposite; -import org.eclipse.jpt.ui.internal.details.IdMappingComposite; -import org.eclipse.jpt.ui.internal.details.ManyToManyMappingComposite; -import org.eclipse.jpt.ui.internal.details.ManyToOneMappingComposite; -import org.eclipse.jpt.ui.internal.details.OneToManyMappingComposite; -import org.eclipse.jpt.ui.internal.details.OneToOneMappingComposite; -import org.eclipse.jpt.ui.internal.details.TransientMappingComposite; -import org.eclipse.jpt.ui.internal.details.VersionMappingComposite; -import org.eclipse.jpt.ui.internal.details.orm.OrmEmbeddableComposite; -import org.eclipse.jpt.ui.internal.details.orm.OrmEntityComposite; -import org.eclipse.jpt.ui.internal.details.orm.OrmMappedSuperclassComposite; -import org.eclipse.jpt.ui.internal.jpa2.details.java.JavaEmbeddedMapping2_0Composite; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 EmbeddableComposite(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.ui/src/org/eclipse/jpt/ui/internal/details/java/DefaultBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/DefaultBasicMappingUiDefinition.java deleted file mode 100644 index 5c36d3ff27..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/DefaultBasicMappingUiDefinition.java +++ /dev/null @@ -1,79 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.ui.internal.details.AbstractBasicMappingUiDefinition; -import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class DefaultBasicMappingUiDefinition - extends AbstractBasicMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/DefaultEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/DefaultEmbeddedMappingUiDefinition.java deleted file mode 100644 index ec942ab7cf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/DefaultEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,79 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddedMappingUiDefinition; -import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class DefaultEmbeddedMappingUiDefinition - extends AbstractEmbeddedMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/GenericJavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/GenericJavaResourceUiDefinition.java deleted file mode 100644 index 9ea0ad6d31..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/GenericJavaResourceUiDefinition.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.ui.internal.details.java; - -import java.util.List; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.ResourceUiDefinition; -import org.eclipse.jpt.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.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.ui/src/org/eclipse/jpt/ui/internal/details/java/GenericJavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/GenericJavaUiFactory.java deleted file mode 100644 index cb83ca7d65..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaBasicMappingUiDefinition.java deleted file mode 100644 index 7e6ebbf5fa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaBasicMappingUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractBasicMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaBasicMappingUiDefinition - extends AbstractBasicMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddableUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddableUiDefinition.java deleted file mode 100644 index 22ea61faa2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddableUiDefinition.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 200 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddableUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaEmbeddableUiDefinition - extends AbstractEmbeddableUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddedIdMappingUDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddedIdMappingUDefinition.java deleted file mode 100644 index 232e50169a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddedIdMappingUDefinition.java +++ /dev/null @@ -1,51 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddedIdMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaEmbeddedIdMappingUDefinition - extends AbstractEmbeddedIdMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddedMappingUiDefinition.java deleted file mode 100644 index e48f90bd36..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,51 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddedMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaEmbeddedMappingUiDefinition - extends AbstractEmbeddedMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEntityComposite.java deleted file mode 100644 index 61f27bae29..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEntityComposite.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEntityComposite; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @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 addSecondaryTablesComposite(Composite container) { - new JavaSecondaryTablesComposite(this, container); - } - - @Override - protected void addInheritanceComposite(Composite container) { - new JavaInheritanceComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEntityUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEntityUiDefinition.java deleted file mode 100644 index cd4de6c459..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaEntityUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEntityUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaEntityUiDefinition - extends AbstractEntityUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaIdMappingUiDefinition.java deleted file mode 100644 index 33066498e1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaIdMappingUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaIdMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractIdMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaIdMappingUiDefinition - extends AbstractIdMappingUiDefinition<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. - */ - private 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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaInheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaInheritanceComposite.java deleted file mode 100644 index 0621afe2cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaInheritanceComposite.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaEntity; -import org.eclipse.jpt.ui.internal.details.AbstractInheritanceComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -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(FormPane<? 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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaManyToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaManyToManyMappingUiDefinition.java deleted file mode 100644 index 61cb1fc453..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaManyToManyMappingUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractManyToManyMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaManyToManyMappingUiDefinition - extends AbstractManyToManyMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaManyToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaManyToOneMappingUiDefinition.java deleted file mode 100644 index 528f6833cf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaManyToOneMappingUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractManyToOneMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaManyToOneMappingUiDefinition - extends AbstractManyToOneMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaMappedSuperclassComposite.java deleted file mode 100644 index 9b19f2e131..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaMappedSuperclassComposite.java +++ /dev/null @@ -1,57 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 2.0 - */ -public class JavaMappedSuperclassComposite extends FormPane<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 JavaMappedSuperclassComposite(PropertyValueModel<? extends JavaMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - new IdClassComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaMappedSuperclassUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaMappedSuperclassUiDefinition.java deleted file mode 100644 index b184dcc192..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaMappedSuperclassUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaMappedSuperclass; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractMappedSuperclassUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaMappedSuperclassUiDefinition - extends AbstractMappedSuperclassUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaOneToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaOneToManyMappingUiDefinition.java deleted file mode 100644 index b12728beb2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaOneToManyMappingUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractOneToManyMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaOneToManyMappingUiDefinition - extends AbstractOneToManyMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaOneToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaOneToOneMappingUiDefinition.java deleted file mode 100644 index 8ca40adaf1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaOneToOneMappingUiDefinition.java +++ /dev/null @@ -1,51 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractOneToOneMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaOneToOneMappingUiDefinition - extends AbstractOneToOneMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentAttributeDetailsPage.java deleted file mode 100644 index 08eb26b412..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentAttributeDetailsPage.java +++ /dev/null @@ -1,68 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.details.PersistentAttributeDetailsPage; -import org.eclipse.jpt.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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentAttributeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentAttributeDetailsProvider.java deleted file mode 100644 index 8db5a44360..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.java; - -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.context.java.JavaStructureNodes; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaDetailsPage; -import org.eclipse.jpt.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.utility.internal.StringTools; -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 StringTools.stringsAreEqual(structureNode.getId(), JavaStructureNodes.PERSISTENT_ATTRIBUTE_ID) - && structureNode.getResourceType().getContentType().equals(JptCorePlugin.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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentTypeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPersistentTypeDetailsProvider.java deleted file mode 100644 index a64b188ac6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.java; - -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.java.JavaStructureNodes; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaDetailsPage; -import org.eclipse.jpt.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.ui.internal.details.PersistentTypeDetailsPage; -import org.eclipse.jpt.utility.internal.StringTools; -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 StringTools.stringsAreEqual(structureNode.getId(), JavaStructureNodes.PERSISTENT_TYPE_ID) - && structureNode.getResourceType().getContentType().equals(JptCorePlugin.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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java deleted file mode 100644 index 8567a2abb7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java +++ /dev/null @@ -1,75 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.core.context.java.JavaEntity; -import org.eclipse.jpt.ui.internal.details.AbstractPrimaryKeyJoinColumnsComposite; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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> -{ - - /** - * Creates a new <code>JavaPrimaryKeyJoinColumnsComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - 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<Entity, PrimaryKeyJoinColumn>(getSubjectHolder(), Entity.DEFAULT_PRIMARY_KEY_JOIN_COLUMN) { - @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(0); - pkJoinColumn.setSpecifiedName(columnName); - pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName); - - this.joinColumnHolder.setValue(pkJoinColumn); - } - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaSecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaSecondaryTablesComposite.java deleted file mode 100644 index 79cf5c2708..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaSecondaryTablesComposite.java +++ /dev/null @@ -1,130 +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.ui.internal.details.java; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.java.JavaEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.AbstractSecondaryTablesComposite; -import org.eclipse.jpt.ui.internal.details.PrimaryKeyJoinColumnsInSecondaryTableComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * Here the layout of this pane: - * <pre> - * ----------------------------------------------------------------------------- - * | ------------------------------------------------------------------------- | - * | | | | - * | | AddRemoveListPane | | - * | | | | - * | ------------------------------------------------------------------------- | - * | ------------------------------------------------------------------------- | - * | | | | - * | | PrimaryKeyJoinColumnsInSecondaryTableComposite | | - * | | | | - * | ------------------------------------------------------------------------- | - * -----------------------------------------------------------------------------</pre> - * - * @see Entity - * @see EntityComposite - The container of this pane - * @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(FormPane<? 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<SecondaryTable> buildSecondaryTablesListModel() { - return new ItemPropertyListValueModelAdapter<SecondaryTable>(buildSecondaryTablesListHolder(), - Table.SPECIFIED_NAME_PROPERTY); - } - - private ListValueModel<SecondaryTable> buildSecondaryTablesListHolder() { - return new ListAspectAdapter<Entity, SecondaryTable>(getSubjectHolder(), Entity.SPECIFIED_SECONDARY_TABLES_LIST) { - @Override - protected ListIterator<SecondaryTable> listIterator_() { - return subject.specifiedSecondaryTables(); - } - - @Override - protected int size_() { - return 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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaTransientMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaTransientMappingUiDefinition.java deleted file mode 100644 index 3ce95a5f99..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaTransientMappingUiDefinition.java +++ /dev/null @@ -1,51 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractTransientMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaTransientMappingUiDefinition - extends AbstractTransientMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaVersionMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaVersionMappingUiDefinition.java deleted file mode 100644 index 2c5d4dc435..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/JavaVersionMappingUiDefinition.java +++ /dev/null @@ -1,51 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.JavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractVersionMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class JavaVersionMappingUiDefinition - extends AbstractVersionMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java deleted file mode 100644 index 929ce59fa3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java +++ /dev/null @@ -1,89 +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.ui.internal.details.java; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.DefaultJavaAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class NullJavaAttributeMappingUiDefinition - 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 FormPane<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.ui/src/org/eclipse/jpt/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java deleted file mode 100644 index 98019c2188..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/java/NullJavaTypeMappingUiDefinition.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.ui.internal.details.java; - -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.java.DefaultJavaTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.java.JavaUiFactory; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class NullJavaTypeMappingUiDefinition implements DefaultJavaTypeMappingUiDefinition<TypeMapping> -{ - - // singleton - private static final NullJavaTypeMappingUiDefinition INSTANCE = new NullJavaTypeMappingUiDefinition(); - - /** - * Return the singleton. - */ - public static DefaultJavaTypeMappingUiDefinition<TypeMapping> 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<TypeMapping> subjectHolder, Composite parent, WidgetFactory widgetFactory) { - return new NullComposite(subjectHolder, parent, widgetFactory); - } - - - public static class NullComposite - extends FormPane<TypeMapping> - implements JpaComposite - { - NullComposite( - PropertyValueModel<TypeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) {} - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java deleted file mode 100644 index f5bd890953..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java +++ /dev/null @@ -1,259 +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.ui.internal.details.orm; - -import java.util.Collection; - -import org.eclipse.jpt.core.context.AccessType; -import org.eclipse.jpt.core.context.orm.EntityMappings; -import org.eclipse.jpt.core.context.orm.PersistenceUnitMetadata; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.AbstractJpaDetailsPage; -import org.eclipse.jpt.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.2 - * @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); - } - - 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().getAccess(); - } - - @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<PersistenceUnitMetadata> buildPersistentUnitMetadataHolder() { - return new TransformationPropertyValueModel<EntityMappings, PersistenceUnitMetadata>(getSubjectHolder()) { - @Override - protected PersistenceUnitMetadata 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(); - } - - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(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 - ); - - // Persistence Unit Metadata widgets - new PersistenceUnitMetadataComposite( - this, - buildPersistentUnitMetadataHolder(), - addSubPane(container, 5) - ); - - // Generators pane - this.buildEntityMappingsGeneratorsComposite(container); - - // Queries pane - this.buildOrmQueriesComposite(container); - } - - protected void buildEntityMappingsGeneratorsComposite(Composite container) { - new EntityMappingsGeneratorsComposite( - this, - container - ); - } - - protected void buildOrmQueriesComposite(Composite container) { - new OrmQueriesComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractOrmEntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractOrmEntityComposite.java deleted file mode 100644 index dc9996d503..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractOrmEntityComposite.java +++ /dev/null @@ -1,91 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.AccessHolder; -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEntityComposite; -import org.eclipse.jpt.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.ui.internal.details.EntityNameComposite; -import org.eclipse.jpt.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.ui.internal.details.TableComposite; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -/** - * The pane used for an ORM entity. - * - * @see OrmEntity - * @see BaseJavaUiFactory - The factory creating this pane - * - * @version 23.0 - * @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) { - initializeGeneralPane(container); - initializeQueriesPane(container); - initializeInheritancePane(container); - initializeAttributeOverridesPane(container); - initializeGeneratorsPane(container); - initializeSecondaryTablesPane(container); - } - - @Override - protected void initializeGeneralPane(Composite container) { - int groupBoxMargin = getGroupBoxMargin(); - - new OrmJavaClassChooser(this, getSubjectHolder(), addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin), false); - new TableComposite(this, container); - new EntityNameComposite(this, addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin)); - new AccessTypeComposite(this, buildAccessHolder(), addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin)); - new IdClassComposite(this, addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin), false); - new MetadataCompleteComposite(this, getSubjectHolder(), addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin)); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<OrmEntity, AccessHolder>( - getSubjectHolder()) - { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } - - @Override - protected void addSecondaryTablesComposite(Composite container) { - new OrmSecondaryTablesComposite(this, container); - } - - @Override - protected void addInheritanceComposite(Composite container) { - new OrmInheritanceComposite(this, container); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java deleted file mode 100644 index 047b7b31eb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java +++ /dev/null @@ -1,168 +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.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.MappingResourceUiDefinition; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.DefaultMappingUiDefinition; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.MappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.utility.internal.Tools; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.utility.internal.iterators.ArrayListIterator; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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>[] ormTypeMappingUiDefintions; - - private OrmAttributeMappingUiDefinition<? extends AttributeMapping>[] ormAttributeMappingUiDefintions; - - 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<? extends TypeMapping>> typeMappingUiDefinitions() { - return new ArrayIterator<MappingUiDefinition<? extends TypeMapping>>(getOrmTypeMappingUiDefinitions()); - } - - protected synchronized OrmTypeMappingUiDefinition<? extends TypeMapping>[] getOrmTypeMappingUiDefinitions() { - if (this.ormTypeMappingUiDefintions == null) { - this.ormTypeMappingUiDefintions = this.buildOrmTypeMappingUiDefinitions(); - } - return this.ormTypeMappingUiDefintions; - } - - - /** - * 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<? 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<? extends AttributeMapping>> attributeMappingUiDefinitions() { - return new ArrayListIterator<MappingUiDefinition<? extends AttributeMapping>>(getOrmAttributeMappingUiDefinitions()); - } - - protected synchronized OrmAttributeMappingUiDefinition<? extends AttributeMapping>[] getOrmAttributeMappingUiDefinitions() { - if (this.ormAttributeMappingUiDefintions == null) { - this.ormAttributeMappingUiDefintions = this.buildOrmAttributeMappingUiDefinitions(); - } - return this.ormAttributeMappingUiDefintions; - } - - /** - * 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<? extends AttributeMapping> getDefaultAttributeMappingUiDefinition(String key) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java deleted file mode 100644 index 44c56d2361..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java +++ /dev/null @@ -1,187 +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.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jpt.core.context.Generator; -import org.eclipse.jpt.ui.internal.widgets.DialogPane; -import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog; -import org.eclipse.jpt.utility.internal.StringConverter; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.StaticListValueModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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> { - - - // ********** constructors ********** - - /** - * Use this constructor to edit an existing conversion value - */ - public AddGeneratorDialog(Shell parent) { - super(parent); - } - - @Override - protected AddGeneratorStateObject buildStateObject() { - return new AddGeneratorStateObject(); - } - - // ********** 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(Generator.TABLE_GENERATOR); - generatorTypes.add(Generator.SEQUENCE_GENERATOR); - - return new StaticListValueModel<String>(generatorTypes); - } - - private StringConverter<String> buildStringConverter() { - return new StringConverter<String>() { - public String convertToString(String value) { - if (value == Generator.TABLE_GENERATOR) { - return JptUiDetailsOrmMessages.AddGeneratorDialog_tableGenerator; - } - if (value == Generator.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.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java deleted file mode 100644 index cd10f5d91e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java +++ /dev/null @@ -1,123 +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.ui.internal.details.orm; - -import java.util.List; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.node.AbstractNode; -import org.eclipse.jpt.utility.internal.node.Node; -import org.eclipse.jpt.utility.internal.node.Problem; - -/** - * 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; - - /** - * 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() { - super(null); - } - - private void addNameProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.name)) { - currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_nameMustBeSpecified)); - } - } - - private void addGeneratorTypeProblemsTo(List<Problem> currentProblems) { - if (StringTools.stringIsEmpty(this.generatorType)) { - currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_typeMustBeSpecified)); - } - } - - @Override - protected void addProblemsTo(List<Problem> currentProblems) { - super.addProblemsTo(currentProblems); - addNameProblemsTo(currentProblems); - addGeneratorTypeProblemsTo(currentProblems); - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/orm/BaseOrmXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/BaseOrmXmlUiFactory.java deleted file mode 100644 index 2a4c3d049a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/BaseOrmXmlUiFactory.java +++ /dev/null @@ -1,143 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmBasicMapping; -import org.eclipse.jpt.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.core.context.orm.OrmEmbeddedMapping; -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.core.context.orm.OrmIdMapping; -import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping; -import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.core.context.orm.OrmVersionMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.BasicMappingComposite; -import org.eclipse.jpt.ui.internal.details.EmbeddedIdMappingComposite; -import org.eclipse.jpt.ui.internal.details.EmbeddedMappingComposite; -import org.eclipse.jpt.ui.internal.details.IdMappingComposite; -import org.eclipse.jpt.ui.internal.details.ManyToManyMappingComposite; -import org.eclipse.jpt.ui.internal.details.ManyToOneMappingComposite; -import org.eclipse.jpt.ui.internal.details.OneToManyMappingComposite; -import org.eclipse.jpt.ui.internal.details.OneToOneMappingComposite; -import org.eclipse.jpt.ui.internal.details.TransientMappingComposite; -import org.eclipse.jpt.ui.internal.details.VersionMappingComposite; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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 IdMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEmbeddedIdMappingComposite( - PropertyValueModel<OrmEmbeddedIdMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new EmbeddedIdMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmBasicMappingComposite( - PropertyValueModel<OrmBasicMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new BasicMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmVersionMappingComposite( - PropertyValueModel<OrmVersionMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new VersionMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmManyToOneMappingComposite( - PropertyValueModel<OrmManyToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new ManyToOneMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmOneToManyMappingComposite( - PropertyValueModel<OrmOneToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OneToManyMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmOneToOneMappingComposite( - PropertyValueModel<OrmOneToOneMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new OneToOneMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmManyToManyMappingComposite( - PropertyValueModel<OrmManyToManyMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new ManyToManyMappingComposite(subjectHolder, parent, widgetFactory); - } - - public JpaComposite createOrmEmbeddedMappingComposite( - PropertyValueModel<OrmEmbeddedMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new EmbeddedMappingComposite(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.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsDetailsPage.java deleted file mode 100644 index 1181b31c08..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.EntityMappings; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -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.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsDetailsProvider.java deleted file mode 100644 index 6e9855ff86..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.orm.EntityMappings; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaDetailsPage; -import org.eclipse.jpt.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.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(JpaResourceType resourceType) { - return resourceType.equals(JptCorePlugin.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.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java deleted file mode 100644 index 25cff384ec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java +++ /dev/null @@ -1,373 +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.ui.internal.details.orm; - -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.core.context.Generator; -import org.eclipse.jpt.core.context.SequenceGenerator; -import org.eclipse.jpt.core.context.TableGenerator; -import org.eclipse.jpt.core.context.orm.EntityMappings; -import org.eclipse.jpt.core.context.orm.OrmGenerator; -import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator; -import org.eclipse.jpt.core.context.orm.OrmTableGenerator; -import org.eclipse.jpt.ui.internal.details.GeneratorComposite; -import org.eclipse.jpt.ui.internal.details.SequenceGeneratorComposite; -import org.eclipse.jpt.ui.internal.details.TableGeneratorComposite; -import org.eclipse.jpt.ui.internal.details.GeneratorComposite.GeneratorBuilder; -import org.eclipse.jpt.ui.internal.util.ControlSwitcher; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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; - private GeneratorComposite<SequenceGenerator> sequenceGeneratorPane; - private 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); - } - - private void addGenerator(ObjectListSelectionModel listSelectionModel) { - addGeneratorFromDialog(listSelectionModel, buildAddGeneratorDialog()); - } - - protected AddGeneratorDialog buildAddGeneratorDialog() { - return new AddGeneratorDialog(getControl().getShell()); - } - - protected void addGeneratorFromDialog(ObjectListSelectionModel listSelectionModel, AddGeneratorDialog dialog) { - if (dialog.open() != Window.OK) { - return; - } - String generatorType = dialog.getGeneratorType(); - OrmGenerator generator; - if (generatorType == Generator.TABLE_GENERATOR) { - generator = this.getSubject().addTableGenerator(getSubject().tableGeneratorsSize()); - } - else if (generatorType == Generator.SEQUENCE_GENERATOR) { - generator = this.getSubject().addSequenceGenerator(getSubject().sequenceGeneratorsSize()); - } - 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(), - Generator.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().sequenceGenerators(), generator); - } - else { - index = CollectionTools.indexOf(getSubject().tableGenerators(), 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 ListIterator<OrmSequenceGenerator> listIterator_() { - return this.subject.sequenceGenerators(); - } - - @Override - protected int size_() { - return this.subject.sequenceGeneratorsSize(); - } - }; - } - - 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 ListIterator<OrmTableGenerator> listIterator_() { - return this.subject.tableGenerators(); - } - - @Override - protected int size_() { - return this.subject.tableGeneratorsSize(); - } - }; - } - - - @Override - protected void initialize() { - super.initialize(); - this.generatorHolder = buildGeneratorHolder(); - } - - @Override - protected void initializeLayout(Composite container) { - - container = addCollapsableSection( - 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.ui/src/org/eclipse/jpt/ui/internal/details/orm/GenericOrmXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/GenericOrmXmlUiFactory.java deleted file mode 100644 index 51a72939e0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -public class GenericOrmXmlUiFactory extends BaseOrmXmlUiFactory -{ - //nothing -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java deleted file mode 100644 index 7fd92f29d5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java +++ /dev/null @@ -1,75 +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.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 Boolean_False; - public static String Boolean_True; - 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 OrmJavaAttributeChooser_javaAttribute; - public static String OrmJavaClassChooser_javaClass; - public static String OrmQueriesComposite_groupBox; - public static String PersistenceUnitMetadataComposite_access; - 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_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.ui/src/org/eclipse/jpt/ui/internal/details/orm/MetadataCompleteComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/MetadataCompleteComposite.java deleted file mode 100644 index 6bd0fff492..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/MetadataCompleteComposite.java +++ /dev/null @@ -1,86 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Composite; - -public class MetadataCompleteComposite extends FormPane<OrmTypeMapping> { - - public MetadataCompleteComposite(FormPane<?> parentPane, - PropertyValueModel<? extends OrmTypeMapping> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - @Override - protected void initializeLayout(Composite container) { - - 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>(buildDefaultMetadataCompleteHolder()) { - @Override - protected String transform(Boolean value) { - if (value != null) { - String defaultStringValue = value.booleanValue() ? JptUiDetailsOrmMessages.Boolean_True : JptUiDetailsOrmMessages.Boolean_False; - return NLS.bind(JptUiDetailsOrmMessages.MetadataCompleteComposite_metadataCompleteWithDefault, defaultStringValue); - } - return JptUiDetailsOrmMessages.MetadataCompleteComposite_metadataComplete; - } - }; - } - private PropertyValueModel<Boolean> buildDefaultMetadataCompleteHolder() { - return new PropertyAspectAdapter<OrmTypeMapping, Boolean>( - getSubjectHolder(), - OrmTypeMapping.SPECIFIED_METADATA_COMPLETE_PROPERTY, - OrmTypeMapping.DEFAULT_METADATA_COMPLETE_PROPERTY) - { - @Override - protected Boolean buildValue_() { - if (this.subject.getSpecifiedMetadataComplete() != null) { - return null; - } - return Boolean.valueOf(this.subject.isDefaultMetadataComplete()); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmBasicMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmBasicMappingUiDefinition.java deleted file mode 100644 index 206d8b680e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmBasicMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmBasicMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractBasicMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmBasicMappingUiDefinition - extends AbstractBasicMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddableComposite.java deleted file mode 100644 index e4f505e15c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddableComposite.java +++ /dev/null @@ -1,49 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.AccessHolder; -import org.eclipse.jpt.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddableComposite extends FormPane<OrmEmbeddable> implements JpaComposite -{ - public OrmEmbeddableComposite(PropertyValueModel<? extends OrmEmbeddable> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddableUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddableUiDefinition.java deleted file mode 100644 index 06fa880372..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddableUiDefinition.java +++ /dev/null @@ -1,50 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddableUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddableUiDefinition - extends AbstractEmbeddableUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddedIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddedIdMappingUiDefinition.java deleted file mode 100644 index 813ea5ca2b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddedIdMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddedIdMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddedIdMappingUiDefinition - extends AbstractEmbeddedIdMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddedMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddedMappingUiDefinition.java deleted file mode 100644 index 44ec2b25c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEmbeddedMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmEmbeddedMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEmbeddedMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmEmbeddedMappingUiDefinition - extends AbstractEmbeddedMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEntityComposite.java deleted file mode 100644 index 8df0695613..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEntityUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEntityUiDefinition.java deleted file mode 100644 index 8fe9b3420d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmEntityUiDefinition.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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractEntityUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmEntityUiDefinition - extends AbstractEntityUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmIdMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmIdMappingUiDefinition.java deleted file mode 100644 index 3741c5efb9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmIdMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmIdMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractIdMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmIdMappingUiDefinition - extends AbstractIdMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmInheritanceComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmInheritanceComposite.java deleted file mode 100644 index 796671f2f9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmInheritanceComposite.java +++ /dev/null @@ -1,44 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.ui.internal.details.AbstractInheritanceComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -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(FormPane<? 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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmJavaAttributeChooser.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmJavaAttributeChooser.java deleted file mode 100644 index ed78daa994..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmJavaAttributeChooser.java +++ /dev/null @@ -1,88 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; - -/** - * @see OrmPersistentAttributeDetailsPage - The parent container - * - * @version 2.0 - * @since 1.0 - */ -public class OrmJavaAttributeChooser extends FormPane<OrmAttributeMapping> -{ - private Text text; - - /** - * 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 OrmJavaAttributeChooser(FormPane<?> parentPane, - PropertyValueModel<OrmAttributeMapping> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - private WritablePropertyValueModel<String> buildNameHolder() { - return new PropertyAspectAdapter<OrmAttributeMapping, String>(getSubjectHolder(), OrmAttributeMapping.NAME_PROPERTY) { - @Override - protected String buildValue_() { - return subject.getName(); - } - - @Override - protected void setValue_(String value) { - if (subject.getPersistentAttribute().isVirtual()) { - return; - } - if (value.length() == 0) { - value = null; - } - subject.setName(value); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - public void enableWidgets(boolean enabled) { - super.enableWidgets(enabled); - - if (!text.isDisposed()) { - text.setEnabled(enabled); - } - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - text = addLabeledText( - container, - JptUiDetailsOrmMessages.OrmJavaAttributeChooser_javaAttribute, - buildNameHolder() - ); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmJavaClassChooser.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmJavaClassChooser.java deleted file mode 100644 index 928caab00a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmJavaClassChooser.java +++ /dev/null @@ -1,112 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<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(FormPane<?> parentPane, - PropertyValueModel<? extends OrmTypeMapping> subjectHolder, - Composite parent) { - - super(parentPane, subjectHolder, parent); - } - - public OrmJavaClassChooser(FormPane<?> 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 JpaProject getJpaProject() { - return getSubject().getJpaProject(); - } - - @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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmManyToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmManyToManyMappingUiDefinition.java deleted file mode 100644 index 719cde9b75..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmManyToManyMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractManyToManyMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmManyToManyMappingUiDefinition - extends AbstractManyToManyMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmManyToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmManyToOneMappingUiDefinition.java deleted file mode 100644 index f6b0dec47f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmManyToOneMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractManyToOneMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmManyToOneMappingUiDefinition - extends AbstractManyToOneMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmMappedSuperclassComposite.java deleted file mode 100644 index 26e62d70ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmMappedSuperclassComposite.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.AccessHolder; -import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.details.AccessTypeComposite; -import org.eclipse.jpt.ui.internal.details.IdClassComposite; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmMappedSuperclassComposite extends FormPane<OrmMappedSuperclass> - implements JpaComposite -{ - - public OrmMappedSuperclassComposite(PropertyValueModel<? extends OrmMappedSuperclass> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) { - new OrmJavaClassChooser(this, getSubjectHolder(), container); - new AccessTypeComposite(this, buildAccessHolder(), container); - new IdClassComposite(this, container); - new MetadataCompleteComposite(this, getSubjectHolder(), container); - } - - protected PropertyValueModel<AccessHolder> buildAccessHolder() { - return new PropertyAspectAdapter<OrmMappedSuperclass, AccessHolder>( - getSubjectHolder()) - { - @Override - protected AccessHolder buildValue_() { - return this.subject.getPersistentType(); - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmMappedSuperclassUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmMappedSuperclassUiDefinition.java deleted file mode 100644 index ecf78137c1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmMappedSuperclassUiDefinition.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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractMappedSuperclassUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmMappedSuperclassUiDefinition - extends AbstractMappedSuperclassUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmOneToManyMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmOneToManyMappingUiDefinition.java deleted file mode 100644 index dea3ccddcc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmOneToManyMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractOneToManyMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmOneToManyMappingUiDefinition - extends AbstractOneToManyMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmOneToOneMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmOneToOneMappingUiDefinition.java deleted file mode 100644 index 9755c3ac56..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmOneToOneMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractOneToOneMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmOneToOneMappingUiDefinition - extends AbstractOneToOneMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPackageChooser.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPackageChooser.java deleted file mode 100644 index e9250a17eb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPackageChooser.java +++ /dev/null @@ -1,119 +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.ui.internal.details.orm; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.context.orm.EntityMappings; -import org.eclipse.jpt.ui.JptUiPlugin; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.ui.internal.widgets.PackageChooserPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<EntityMappings> -{ - /** - * Creates a new <code>XmlPackageChooser</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - public OrmPackageChooser(FormPane<? 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 IPackageFragmentRoot getPackageFragmentRoot() { - IProject project = getSubject().getJpaProject().getProject(); - IJavaProject root = JavaCore.create(project); - - try { - return root.getAllPackageFragmentRoots()[0]; - } - catch (JavaModelException e) { - JptUiPlugin.log(e); - } - - return null; - } - - @Override - protected String getPackageName() { - return getSubject().getPackage(); - } - - @Override - protected void promptPackage() { - IPackageFragment packageFragment = choosePackage(); - - if (packageFragment != null) { - String packageName = packageFragment.getElementName(); - getSubject().setPackage(packageName); - } - } - }; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentAttributeDetailsPage.java deleted file mode 100644 index 33e5dabf1a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentAttributeDetailsPage.java +++ /dev/null @@ -1,127 +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.ui.internal.details.orm; - -import java.util.ArrayList; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.internal.details.PersistentAttributeDetailsPage; -import org.eclipse.jpt.ui.internal.details.PersistentAttributeMapAsComposite; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.0 - * @since 2.0 - */ -public class OrmPersistentAttributeDetailsPage extends PersistentAttributeDetailsPage<OrmPersistentAttribute> -{ - /** - * 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); - - // Entity type widgets - OrmJavaAttributeChooser javaAttributePane = - new OrmJavaAttributeChooser(this, getMappingHolder(), container); - - panes.add(javaAttributePane); - - buildMappingPageBook(container); - - installPaneEnabler(panes); - } - - protected Pane<PersistentAttribute> 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<OrmPersistentAttribute, Boolean>(getSubjectHolder()) { - @Override - protected Boolean transform_(OrmPersistentAttribute value) { - return Boolean.valueOf(!value.isVirtual()); - } - }; - } - - private PropertyValueModel<OrmAttributeMapping> getMappingHolder() { - return new TransformationPropertyValueModel<PersistentAttribute, OrmAttributeMapping>(getSubjectHolder()) { - @Override - protected OrmAttributeMapping transform_(PersistentAttribute value) { - return (OrmAttributeMapping) value.getMapping(); - } - }; - } - - //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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentAttributeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentAttributeDetailsProvider.java deleted file mode 100644 index e848ce8d04..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmStructureNodes; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaDetailsPage; -import org.eclipse.jpt.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.utility.internal.StringTools; -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 StringTools.stringsAreEqual(structureNode.getId(), OrmStructureNodes.PERSISTENT_ATTRIBUTE_ID) - && structureNode.getResourceType().getContentType().isKindOf(JptCorePlugin.MAPPING_FILE_CONTENT_TYPE); - } - - public JpaDetailsPage<OrmPersistentAttribute> buildDetailsPage( - Composite parent, - WidgetFactory widgetFactory) { - - return new OrmPersistentAttributeDetailsPage(parent, widgetFactory); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentTypeDetailsProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPersistentTypeDetailsProvider.java deleted file mode 100644 index 668fd4e46e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.orm.OrmStructureNodes; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaDetailsPage; -import org.eclipse.jpt.ui.details.JpaDetailsProvider; -import org.eclipse.jpt.ui.internal.details.PersistentTypeDetailsPage; -import org.eclipse.jpt.utility.internal.StringTools; -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 StringTools.stringsAreEqual(structureNode.getId(), OrmStructureNodes.PERSISTENT_TYPE_ID) - && structureNode.getResourceType().getContentType().isKindOf(JptCorePlugin.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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java deleted file mode 100644 index 9c518aeb7f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java +++ /dev/null @@ -1,78 +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.ui.internal.details.orm; - -import java.util.ListIterator; -import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn; -import org.eclipse.jpt.ui.internal.details.AbstractPrimaryKeyJoinColumnsComposite; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -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> -{ - - /** - * Creates a new <code>OrmPrimaryKeyJoinColumnsComposite</code>. - * - * @param parentPane The parent controller of this one - * @param parent The parent container - */ - public OrmPrimaryKeyJoinColumnsComposite(Pane<? extends OrmEntity> subjectHolder, - Composite parent) { - - super(subjectHolder, parent); - } - - @Override - protected ListValueModel<OrmPrimaryKeyJoinColumn> buildDefaultJoinColumnsListHolder() { - return new ListAspectAdapter<OrmEntity, OrmPrimaryKeyJoinColumn>( - getSubjectHolder(), - OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST) - { - @Override - protected ListIterator<OrmPrimaryKeyJoinColumn> listIterator_() { - return subject.defaultPrimaryKeyJoinColumns(); - } -//TODO defaultPrimaryKeyJoinColumnsSize when I can change the API -// @Override -// protected int size_() { -// return subject.defaultPrimaryKeyJoinColumnsSize(); -// } - }; - } - - @Override - protected void switchDefaultToSpecified() { - ListIterator<OrmPrimaryKeyJoinColumn> defaultJoinColumns = getSubject().defaultPrimaryKeyJoinColumns(); - - int index = 0; - while (defaultJoinColumns.hasNext()) { - OrmPrimaryKeyJoinColumn defaultJoinColumn = defaultJoinColumns.next(); - String columnName = defaultJoinColumn.getName(); - String referencedColumnName = defaultJoinColumn.getReferencedColumnName(); - - PrimaryKeyJoinColumn pkJoinColumn = getSubject().addSpecifiedPrimaryKeyJoinColumn(index++); - pkJoinColumn.setSpecifiedName(columnName); - pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName); - } - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java deleted file mode 100644 index a9cd33d78f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.QueryContainer; -import org.eclipse.jpt.core.context.orm.EntityMappings; -import org.eclipse.jpt.ui.internal.details.QueriesComposite; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.Pane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -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.addCollapsableSection( - 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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmSecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmSecondaryTablesComposite.java deleted file mode 100644 index 283d5098c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmSecondaryTablesComposite.java +++ /dev/null @@ -1,209 +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.ui.internal.details.orm; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.SecondaryTable; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.orm.OrmEntity; -import org.eclipse.jpt.core.context.orm.OrmSecondaryTable; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.AbstractSecondaryTablesComposite; -import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages; -import org.eclipse.jpt.ui.internal.details.PrimaryKeyJoinColumnsInSecondaryTableComposite; -import org.eclipse.jpt.ui.internal.details.SecondaryTableDialog; -import org.eclipse.jpt.ui.internal.util.PaneEnabler; -import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel; -import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter; -import org.eclipse.jpt.utility.model.value.ListValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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(FormPane<? 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<OrmSecondaryTable> buildSecondaryTablesListHolder() { - List<ListValueModel<OrmSecondaryTable>> list = new ArrayList<ListValueModel<OrmSecondaryTable>>(); - list.add(buildSpecifiedSecondaryTablesListHolder()); - list.add(buildVirtualSecondaryTablesListHolder()); - return new CompositeListValueModel<ListValueModel<OrmSecondaryTable>, OrmSecondaryTable>(list); - } - - private ListValueModel<OrmSecondaryTable> buildSecondaryTablesListModel() { - return new ItemPropertyListValueModelAdapter<OrmSecondaryTable>(buildSecondaryTablesListHolder(), - Table.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(); - } - }; - } - - private ListValueModel<OrmSecondaryTable> buildVirtualSecondaryTablesListHolder() { - return new ListAspectAdapter<OrmEntity, OrmSecondaryTable>(getSubjectHolder(), OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST) { - @Override - protected ListIterator<OrmSecondaryTable> listIterator_() { - return 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( - getControl().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().secondaryTablesDefinedInXml()); - } - - public void setValue(Boolean value) { - getSubject().setSecondaryTablesDefinedInXml(value.booleanValue()); - } - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmTransientMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmTransientMappingUiDefinition.java deleted file mode 100644 index 5e174bb048..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmTransientMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractTransientMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmTransientMappingUiDefinition - extends AbstractTransientMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmVersionMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmVersionMappingUiDefinition.java deleted file mode 100644 index a913d90eb0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmVersionMappingUiDefinition.java +++ /dev/null @@ -1,52 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.orm.OrmVersionMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.details.AbstractVersionMappingUiDefinition; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.widgets.Composite; - -public class OrmVersionMappingUiDefinition - extends AbstractVersionMappingUiDefinition<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.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmXmlUiDefinition.java deleted file mode 100644 index ff8a35594d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmXmlUiDefinition.java +++ /dev/null @@ -1,80 +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.ui.internal.details.orm; - -import java.util.List; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.ui.ResourceUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmTypeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.structure.OrmResourceModelStructureProvider; -import org.eclipse.jpt.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(JpaResourceType resourceType) { - return resourceType.equals(JptCorePlugin.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.ui/src/org/eclipse/jpt/ui/internal/details/orm/PersistenceUnitMetadataComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/PersistenceUnitMetadataComposite.java deleted file mode 100644 index 2cfdcf97e8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/PersistenceUnitMetadataComposite.java +++ /dev/null @@ -1,268 +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.ui.internal.details.orm; - -import java.util.Collection; -import org.eclipse.jpt.core.context.AccessType; -import org.eclipse.jpt.core.context.orm.OrmPersistenceUnitDefaults; -import org.eclipse.jpt.core.context.orm.PersistenceUnitMetadata; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.ui.internal.JpaHelpContextIds; -import org.eclipse.jpt.ui.internal.details.db.CatalogCombo; -import org.eclipse.jpt.ui.internal.details.db.SchemaCombo; -import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; -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 FormPane<PersistenceUnitMetadata> -{ - /** - * 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(FormPane<?> parentPane, - PropertyValueModel<? extends PersistenceUnitMetadata> 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 subject.isCascadePersist(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setCascadePersist(value); - } - }; - } - - 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<PersistenceUnitMetadata, OrmPersistenceUnitDefaults>(getSubjectHolder()) { - @Override - protected OrmPersistenceUnitDefaults transform_(PersistenceUnitMetadata 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<PersistenceUnitMetadata, Boolean>(getSubjectHolder(), PersistenceUnitMetadata.XML_MAPPING_METADATA_COMPLETE_PROPERTY) { - @Override - protected Boolean buildValue_() { - return subject.isXmlMappingMetadataComplete(); - } - - @Override - protected void setValue_(Boolean value) { - subject.setXmlMappingMetadataComplete(value); - } - }; - } - - /* - * (non-Javadoc) - */ - @Override - protected void initializeLayout(Composite container) { - - // Section - container = addCollapsableSection( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_persistenceUnitSection - ); - - // XML mapping metadata complete check box - addCheckBox( - container, - JptUiDetailsOrmMessages.PersistenceUnitMetadataComposite_xmlMappingMetadataCompleteCheckBox, - buildXmlMappingMetadataCompleteHolder(), - JpaHelpContextIds.ENTITY_ORM_XML - ); - - // Cascade Persist widgets - 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 - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/UnsupportedOrmMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/UnsupportedOrmMappingUiDefinition.java deleted file mode 100644 index ce387521ba..0000000000 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/UnsupportedOrmMappingUiDefinition.java +++ /dev/null @@ -1,82 +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.ui.internal.details.orm; - -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.ui.WidgetFactory; -import org.eclipse.jpt.ui.details.JpaComposite; -import org.eclipse.jpt.ui.details.orm.OrmAttributeMappingUiDefinition; -import org.eclipse.jpt.ui.details.orm.OrmXmlUiFactory; -import org.eclipse.jpt.ui.internal.JpaMappingImageHelper; -import org.eclipse.jpt.ui.internal.widgets.FormPane; -import org.eclipse.jpt.utility.model.value.PropertyValueModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class UnsupportedOrmMappingUiDefinition - implements OrmAttributeMappingUiDefinition -{ - // singleton - private static final UnsupportedOrmMappingUiDefinition INSTANCE = - new UnsupportedOrmMappingUiDefinition(); - - /** - * Return the singleton. - */ - public static OrmAttributeMappingUiDefinition instance() { - return INSTANCE; - } - - - 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; - } - /** - * Ensure single instance. - */ - private UnsupportedOrmMappingUiDefinition() { - super(); - } - - public JpaComposite buildAttributeMappingComposite( - OrmXmlUiFactory factory, - PropertyValueModel subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - return new NullComposite(subjectHolder, parent, widgetFactory); - } - - public static class NullComposite extends FormPane<JavaAttributeMapping> - implements JpaComposite - { - NullComposite( - PropertyValueModel<JavaAttributeMapping> subjectHolder, - Composite parent, - WidgetFactory widgetFactory) { - super(subjectHolder, parent, widgetFactory); - } - - @Override - protected void initializeLayout(Composite container) {} - } -} |