Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-04-02 14:34:38 +0000
committerkmoore2010-04-02 14:34:38 +0000
commit3fefdb0f2a4d6cc4c70b3b6c11ed18d73fc53c85 (patch)
tree0c17eaea515ffcdcf5e35f4728c072d04c9d4052
parent9c19471e775539f8496e92582a64319f9015178c (diff)
downloadwebtools.dali-3fefdb0f2a4d6cc4c70b3b6c11ed18d73fc53c85.tar.gz
webtools.dali-3fefdb0f2a4d6cc4c70b3b6c11ed18d73fc53c85.tar.xz
webtools.dali-3fefdb0f2a4d6cc4c70b3b6c11ed18d73fc53c85.zip
changed the 'ID is mapped by a relationship' tag to just be a label that is removed if it does not apply
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/ControlSwitcher.java82
4 files changed, 99 insertions, 74 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties
index 146b4f778d..6114fe4d25 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties
@@ -30,8 +30,8 @@ AbstractElementCollectionMapping2_0_Composite_valueSectionTitle=Value
Entity_cacheableLabel=Cacheable
Entity_cacheableWithDefaultLabel=Cacheable ({0})
-EmbeddedIdMapping2_0MappedByRelationshipPane_label=This embedded ID is mapped by a relationship
-IdMapping2_0MappedByRelationshipPane_label=This ID is mapped by a relationship
+EmbeddedIdMapping2_0MappedByRelationshipPane_label=Embedded ID is mapped by a relationship.
+IdMapping2_0MappedByRelationshipPane_label=ID is mapped by a relationship.
OrderingComposite_orderColumn=Order column
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java
index 56cd1d15ab..a37eddbe62 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/EmbeddedIdMapping2_0MappedByRelationshipPane.java
@@ -11,16 +11,24 @@
package org.eclipse.jpt.ui.internal.jpa2.details;
import org.eclipse.jpt.core.jpa2.context.EmbeddedIdMapping2_0;
+import org.eclipse.jpt.ui.internal.util.ControlSwitcher;
import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.Transformer;
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.Button;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.PageBook;
public class EmbeddedIdMapping2_0MappedByRelationshipPane<T extends EmbeddedIdMapping2_0>
extends Pane<T>
{
+ private Label mappedByRelationshipLabel;
+
public EmbeddedIdMapping2_0MappedByRelationshipPane(
Pane<?> parentPane,
PropertyValueModel<T> subjectHolder,
@@ -28,26 +36,34 @@ public class EmbeddedIdMapping2_0MappedByRelationshipPane<T extends EmbeddedIdMa
super(parentPane, subjectHolder, parent);
}
-
-
+
@Override
protected void initializeLayout(Composite container) {
- Composite subContainer = addSubPane(container, 2, 10, 0, 0, 0);
- Button checkBox = addCheckBox(
- subContainer,
- null,
- buildIsMappedByRelationshipHolder(),
- null);
- checkBox.setEnabled(false);
- addLabel(subContainer, JptUiDetailsMessages2_0.EmbeddedIdMapping2_0MappedByRelationshipPane_label);
+ PageBook pageBook = new PageBook(container, SWT.NULL);
+ pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ this.mappedByRelationshipLabel = addLabel(pageBook, JptUiDetailsMessages2_0.EmbeddedIdMapping2_0MappedByRelationshipPane_label);
+
+ new ControlSwitcher(buildIsMappedByRelationshipHolder(), buildPaneTransformer(), pageBook);
}
-
+
protected WritablePropertyValueModel<Boolean> buildIsMappedByRelationshipHolder() {
return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), EmbeddedIdMapping2_0.MAPPED_BY_RELATIONSHIP_PROPERTY) {
@Override
protected Boolean buildValue_() {
- return this.subject.isMappedByRelationship();
+ return Boolean.valueOf(this.subject.isMappedByRelationship());
}
};
- }
+ }
+
+ private Transformer<Boolean, Control> buildPaneTransformer() {
+ return new Transformer<Boolean, Control>() {
+ public Control transform(Boolean converter) {
+ if (converter == null || converter == Boolean.FALSE) {
+ return null;
+ }
+ return EmbeddedIdMapping2_0MappedByRelationshipPane.this.mappedByRelationshipLabel;
+ }
+ };
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java
index e13239c05a..3e1fbdf219 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/IdMapping2_0MappedByRelationshipPane.java
@@ -11,17 +11,26 @@
package org.eclipse.jpt.ui.internal.jpa2.details;
import org.eclipse.jpt.core.jpa2.context.IdMapping2_0;
+import org.eclipse.jpt.ui.internal.util.ControlSwitcher;
import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.Transformer;
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.Button;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.PageBook;
public class IdMapping2_0MappedByRelationshipPane<T extends IdMapping2_0>
extends Pane<T>
{
+
+ private Label mappedByRelationshipLabel;
+
public IdMapping2_0MappedByRelationshipPane(
Pane<?> parentPane,
PropertyValueModel<T> subjectHolder,
@@ -29,25 +38,33 @@ public class IdMapping2_0MappedByRelationshipPane<T extends IdMapping2_0>
super(parentPane, subjectHolder, parent);
}
-
-
+
@Override
protected void initializeLayout(Composite container) {
- Composite subContainer = addSubPane(container, 2, 0, 0, 0, 0);
- Button checkBox = addCheckBox(
- subContainer,
- null,
- buildIsMappedByRelationshipHolder(),
- null);
- checkBox.setEnabled(false);
- addLabel(subContainer, JptUiDetailsMessages2_0.IdMapping2_0MappedByRelationshipPane_label);
+ PageBook pageBook = new PageBook(container, SWT.NULL);
+ pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ this.mappedByRelationshipLabel = addLabel(pageBook, JptUiDetailsMessages2_0.IdMapping2_0MappedByRelationshipPane_label);
+
+ new ControlSwitcher(buildIsMappedByRelationshipHolder(), buildPaneTransformer(), pageBook);
}
-
+
protected WritablePropertyValueModel<Boolean> buildIsMappedByRelationshipHolder() {
return new PropertyAspectAdapter<T, Boolean>(getSubjectHolder(), IdMapping2_0.MAPPED_BY_RELATIONSHIP_PROPERTY) {
@Override
protected Boolean buildValue_() {
- return this.subject.isMappedByRelationship();
+ return Boolean.valueOf(this.subject.isMappedByRelationship());
+ }
+ };
+ }
+
+ private Transformer<Boolean, Control> buildPaneTransformer() {
+ return new Transformer<Boolean, Control>() {
+ public Control transform(Boolean converter) {
+ if (converter == null || converter == Boolean.FALSE) {
+ return null;
+ }
+ return IdMapping2_0MappedByRelationshipPane.this.mappedByRelationshipLabel;
}
};
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/ControlSwitcher.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/ControlSwitcher.java
index 1efb77d9f4..944631a796 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/ControlSwitcher.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/ControlSwitcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -24,7 +24,7 @@ import org.eclipse.ui.part.PageBook;
* <code>Transformer</code> is used to transformed that value into a
* <code>Control</code>.
*
- * @version 2.0
+ * @version 2.3
* @since 2.0
*/
public final class ControlSwitcher
@@ -40,6 +40,8 @@ public final class ControlSwitcher
*/
private Transformer<?, Control> paneTransformer;
+ private Label emptyLabel;
+
/**
* Creates a new <code>ControlSwitcher</code>.
*
@@ -58,30 +60,6 @@ public final class ControlSwitcher
initialize(switchHolder, paneTransformer, pageBook);
}
- private PropertyChangeListener buildPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(
- buildPropertyChangeListener_()
- );
- }
-
- private PropertyChangeListener buildPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- switchPanes(e.getNewValue());
- }
- };
- }
-
- /**
- * Initializes this <code>ControlSwitcher</code>.
- *
- * @param switchHolder The holder of the value that will be used to retrieve
- * the right <code>Control</code> when passed to the given transformer
- * @param paneTransformer The <code>Transformer</code> used to transform the value into a
- * <code>Control</code>
- * @param pageBook The <code>Transformer</code> used to transform the value
- * into a <code>Control</code>
- */
private void initialize(PropertyValueModel<?> switchHolder,
Transformer<?, Control> paneTransformer,
PageBook pageBook)
@@ -89,12 +67,35 @@ public final class ControlSwitcher
this.pageBook = pageBook;
this.paneTransformer = paneTransformer;
+ this.emptyLabel = this.buildEmptyLabel();
+
switchHolder.addPropertyChangeListener(
PropertyValueModel.VALUE,
buildPropertyChangeListener()
);
- switchPanes(switchHolder.getValue());
+ switchPages(switchHolder.getValue());
+ }
+
+ //Build an empty label to display in the page book when the paneTransformer returns null.
+ //SWT.SHADOW_NONE makes the line separator not visible
+ //This is the best we can come up with for an empty page
+ private Label buildEmptyLabel() {
+ return new Label(this.pageBook, SWT.SEPARATOR | SWT.SHADOW_NONE | SWT.HORIZONTAL);
+ }
+
+ private PropertyChangeListener buildPropertyChangeListener() {
+ return new SWTPropertyChangeListenerWrapper(
+ buildPropertyChangeListener_()
+ );
+ }
+
+ private PropertyChangeListener buildPropertyChangeListener_() {
+ return new PropertyChangeListener() {
+ public void propertyChanged(PropertyChangeEvent e) {
+ switchPages(e.getNewValue());
+ }
+ };
}
/**
@@ -104,35 +105,26 @@ public final class ControlSwitcher
* @param value The state passed to the transformer in order to retrieve the
* new pane
*/
- private void switchPanes(Object value) {
-
- if (pageBook.isDisposed()) {
+ private void switchPages(Object value) {
+ if (this.pageBook.isDisposed()) {
return;
}
// Retrieve the Control for the new value
- Control pane = transform(value);
- boolean visible = (pane != null);
-
- // Show the new page
- if (visible) {
- pageBook.showPage(pane);
- }
- else {
- // Note: We can't null due to a bug in PageBook
- pageBook.showPage(new Label(pageBook, SWT.SEPARATOR | SWT.HORIZONTAL));
- }
+ Control page = transform(value);
- if (pageBook.isVisible() != visible) {
- pageBook.setVisible(visible);
+ if (page == null) {
+ //Note: We can't pass in null due to a bug in PageBook
+ page = this.emptyLabel;
}
+ this.pageBook.showPage(page);
// Revalidate the parents in order to update the layout
- SWTUtil.reflow(pageBook);
+ SWTUtil.reflow(this.pageBook);
}
@SuppressWarnings("unchecked")
private Control transform(Object value) {
- return ((Transformer<Object, Control>) paneTransformer).transform(value);
+ return ((Transformer<Object, Control>) this.paneTransformer).transform(value);
}
} \ No newline at end of file

Back to the top