blob: 989203c224dc868bee7c4a59a1af1782ce170c6a [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0, which accompanies this distribution
* and is available at https://www.eclipse.org/legal/epl-2.0/.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.details;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.SpecifiedAccessReference;
import org.eclipse.jpt.jpa.core.context.Embeddable;
import org.eclipse.jpt.jpa.ui.details.JpaComposite;
import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.Section;
public abstract class AbstractEmbeddableComposite<E extends Embeddable>
extends Pane<E>
implements JpaComposite
{
protected AbstractEmbeddableComposite(
PropertyValueModel<? extends E> embeddableModel,
Composite parentComposite,
WidgetFactory widgetFactory,
ResourceManager resourceManager) {
super(embeddableModel, parentComposite, widgetFactory, resourceManager);
}
@Override
protected void initializeLayout(Composite container) {
this.initializeEmbeddableCollapsibleSection(container);
}
protected void initializeEmbeddableCollapsibleSection(Composite container) {
final Section section = this.getWidgetFactory().createSection(container,
ExpandableComposite.TITLE_BAR |
ExpandableComposite.TWISTIE |
ExpandableComposite.EXPANDED);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
section.setText(JptJpaUiDetailsMessages.EMBEDDABLE_SECTION_TITLE);
section.setClient(this.buildEmbeddableSectionClient(section));
}
protected abstract Control buildEmbeddableSectionClient(Section embeddableSection);
protected PropertyValueModel<SpecifiedAccessReference> buildAccessReferenceModel() {
return new PropertyAspectAdapter<E, SpecifiedAccessReference>(this.getSubjectHolder()) {
@Override
protected SpecifiedAccessReference buildValue_() {
return this.subject.getPersistentType();
}
};
}
}