Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-08-05 13:42:24 +0000
committerkmoore2008-08-05 13:42:24 +0000
commit8f0d48f475f4d93eefdc57ab0b0c5317b4da34df (patch)
tree4c391685e2262d2c124063c20a320e019b045b19 /jpa/plugins
parentc0d25fcef1ca4abe9846178eac2e1aebcf2e2de7 (diff)
downloadwebtools.dali-8f0d48f475f4d93eefdc57ab0b0c5317b4da34df.tar.gz
webtools.dali-8f0d48f475f4d93eefdc57ab0b0c5317b4da34df.tar.xz
webtools.dali-8f0d48f475f4d93eefdc57ab0b0c5317b4da34df.zip
cache size widget, created advanced section on caching composite
Diffstat (limited to 'jpa/plugins')
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties3
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheSizeComposite.java176
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java36
4 files changed, 209 insertions, 10 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties
index 2290c07768..53af7896b1 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties
@@ -18,6 +18,8 @@ CacheTypeComposite_hard_weak = Weak with Hard Subcache
CacheTypeComposite_cache = Cache
CacheTypeComposite_none = None
+CacheSizeComposite_size = Size:
+
CacheCoordinationTypeComposite_label = Coordination Type:
CacheCoordinationTypeComposite_send_object_changes = Send Object Changes
CacheCoordinationTypeComposite_invalidate_changed_objects = Invalidate Changed Objects
@@ -26,6 +28,7 @@ CacheCoordinationTypeComposite_none = None
CachingComposite_sharedLabelDefault = Shared ({0})
CachingComposite_sharedLabel = Shared
+CachingComposite_advanced = Advanced
AlwaysRefreshComposite_alwaysRefreshDefault = Always Refresh ({0})
AlwaysRefreshComposite_alwaysRefreshLabel = Always Refresh
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java
index 3605f6f2fb..35b9c3793f 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java
@@ -29,7 +29,8 @@ public class EclipseLinkUiMappingsMessages extends NLS {
public static String CacheTypeComposite_cache;
public static String CacheTypeComposite_none;
public static String EclipseLinkJavaEntityComposite_caching;
-
+
+ public static String CacheSizeComposite_size;
public static String CacheCoordinationTypeComposite_label;
public static String CacheCoordinationTypeComposite_send_object_changes;
public static String CacheCoordinationTypeComposite_invalidate_changed_objects;
@@ -38,6 +39,7 @@ public class EclipseLinkUiMappingsMessages extends NLS {
public static String CachingComposite_sharedLabelDefault;
public static String CachingComposite_sharedLabel;
+ public static String CachingComposite_advanced;
public static String AlwaysRefreshComposite_alwaysRefreshDefault;
public static String AlwaysRefreshComposite_alwaysRefreshLabel;
public static String RefreshOnlyIfNewerComposite_refreshOnlyIfNewerDefault;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheSizeComposite.java
new file mode 100644
index 0000000000..3cf27cf686
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CacheSizeComposite.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * 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.eclipselink.ui.internal.mappings.details;
+
+import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching;
+import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
+import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+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.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+
+/**
+ * Here is the layout of this pane:
+ * <pre>
+ * ----------------------------------------------------------------------------
+ * | --------------- |
+ * | Size: | I |I| Default (XXX) |
+ * | --------------- |
+ * ----------------------------------------------------------------------------</pre>
+ *
+ * @see EclipseLinkCaching
+ * @see CachingComposite - A container of this widget
+ *
+ * @version 2.1
+ * @since 2.1
+ */
+public class CacheSizeComposite extends AbstractFormPane<EclipseLinkCaching> {
+
+ /**
+ * Creates a new <code>CacheSizeComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public CacheSizeComposite(AbstractFormPane<? extends EclipseLinkCaching> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ // Size widgets
+ Spinner sizeSpinner = buildLabeledSpinner(
+ container,
+ EclipseLinkUiMappingsMessages.CacheSizeComposite_size,
+ buildSizeHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ buildDefaultSizeLabel(container)//,
+ //TODO JpaHelpContextIds.MAPPING_COLUMN_LENGTH
+ );
+
+ updateGridData(container, sizeSpinner);
+ }
+
+ private WritablePropertyValueModel<Integer> buildSizeHolder() {
+ return new PropertyAspectAdapter<EclipseLinkCaching, Integer>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return subject.getSpecifiedSize();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value == -1) {
+ value = null;
+ }
+ subject.setSpecifiedSize(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Integer> buildDefaultSizeHolder() {
+ return new PropertyAspectAdapter<EclipseLinkCaching, Integer>(getSubjectHolder(), EclipseLinkCaching.DEFAULT_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return subject.getDefaultSize();
+ }
+
+ @Override
+ protected void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Integer.MIN_VALUE, newValue);
+ }
+ }
+ };
+ }
+
+ private Control buildDefaultSizeLabel(Composite container) {
+
+ Label label = buildLabel(
+ container,
+ JptUiMappingsMessages.DefaultWithoutValue
+ );
+
+ new LabeledControlUpdater(
+ new LabeledLabel(label),
+ buildDefaultSizeLabelHolder()
+ );
+
+ return label;
+ }
+
+ private PropertyValueModel<String> buildDefaultSizeLabelHolder() {
+
+ return new TransformationPropertyValueModel<Integer, String>(buildDefaultSizeHolder()) {
+
+ @Override
+ protected String transform(Integer value) {
+
+ Integer defaultValue = (subject() != null) ? subject().getDefaultSize() :
+ EclipseLinkCaching.DEFAULT_SIZE;
+
+ return NLS.bind(
+ JptUiMappingsMessages.DefaultWithValue,
+ defaultValue
+ );
+ }
+ };
+ }
+
+ /**
+ * Changes the layout of the given container by changing which widget will
+ * grab the excess of horizontal space. By default, the center control grabs
+ * the excess space, we change it to be the right control.
+ *
+ * @param container The container containing the controls needing their
+ * <code>GridData</code> to be modified from the default values
+ * @param spinner The spinner that got created
+ */
+ private void updateGridData(Composite container, Spinner spinner) {
+
+ // It is possible the spinner's parent is not the container of the
+ // label, spinner and right control (a pane is sometimes required for
+ // painting the spinner's border)
+ Composite paneContainer = spinner.getParent();
+
+ while (container != paneContainer.getParent()) {
+ paneContainer = paneContainer.getParent();
+ }
+
+ Control[] controls = paneContainer.getChildren();
+
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = false;
+ gridData.horizontalAlignment = GridData.BEGINNING;
+ controls[1].setLayoutData(gridData);
+
+ controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeAlignRight(controls[2]);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java
index 7b0ab4e25c..9fbc9dbcb1 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java
@@ -9,13 +9,17 @@
******************************************************************************/
package org.eclipse.jpt.eclipselink.ui.internal.mappings.details;
+import java.util.ArrayList;
+import java.util.Collection;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkHelpContextIds;
import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.util.PaneEnabler;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
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;
@@ -70,18 +74,32 @@ public class CachingComposite extends AbstractFormPane<EclipseLinkCaching>
Composite subPane = buildSubPane(container, 0, 16);
- new PaneEnabler(buildSharedCacheEnabler(),
- new CacheTypeComposite(this, subPane),
- new AlwaysRefreshComposite(this, subPane),
- new RefreshOnlyIfNewerComposite(this, subPane),
- new DisableHitsComposite(this, subPane),
- new CacheCoordinationTypeComposite(this, subPane)
- );
+ Collection<AbstractPane<?>> panes = new ArrayList<AbstractPane<?>>();
+
+ panes.add(new CacheTypeComposite(this, subPane));
+ panes.add(new CacheSizeComposite(this, subPane));
+
+ // Advanced sub-pane
+ Composite advancedSection = buildCollapsableSubSection(
+ subPane,
+ EclipseLinkUiMappingsMessages.CachingComposite_advanced,
+ new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
+ );
+
+ initializeAdvancedPane(buildSubPane(advancedSection, 0, 16), panes);
+
+ new PaneEnabler(buildSharedCacheEnabler(), panes);
new ExistenceCheckingComposite(this, buildSubPane(container, 8));
}
-
-
+
+ private void initializeAdvancedPane(Composite container, Collection<AbstractPane<?>> panes) {
+ panes.add(new AlwaysRefreshComposite(this, container));
+ panes.add(new RefreshOnlyIfNewerComposite(this, container));
+ panes.add(new DisableHitsComposite(this, container));
+ panes.add(new CacheCoordinationTypeComposite(this, container));
+ }
+
private PropertyValueModel<Boolean> buildSharedCacheEnabler() {
return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_SHARED_PROPERTY) {
@Override

Back to the top