diff options
author | Tor Norbye <tnorbye@google.com> | 2012-04-04 18:36:45 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-04-05 12:04:22 -0700 |
commit | 765e52e2d30d0754625b8c7af6c36e93612f15be (patch) | |
tree | c56a08ff179924eff51f0020fe530c8fd895406b /propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/presentation/CompoundPropertyEditorPresentation.java | |
parent | b33fa4c8ce6b3d2c10eaa92c5c26019d7326bd4c (diff) | |
download | eclipse-windowbuilder-765e52e2d30d0754625b8c7af6c36e93612f15be.tar.gz |
Add WindowBuilder propertysheet code. See README.txt for details.
This reverts commit b33fa4c8ce6b3d2c10eaa92c5c26019d7326bd4c.
Change-Id: I763357c42f933a52eda9b52988b785e092eac424
Diffstat (limited to 'propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/presentation/CompoundPropertyEditorPresentation.java')
-rw-r--r-- | propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/presentation/CompoundPropertyEditorPresentation.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/presentation/CompoundPropertyEditorPresentation.java b/propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/presentation/CompoundPropertyEditorPresentation.java new file mode 100644 index 0000000..39bfa7a --- /dev/null +++ b/propertysheet/src/org/eclipse/wb/internal/core/model/property/editor/presentation/CompoundPropertyEditorPresentation.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Google, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.wb.internal.core.model.property.editor.presentation; + +import com.google.common.collect.Lists; + +import org.eclipse.wb.internal.core.model.property.Property; +import org.eclipse.wb.internal.core.model.property.table.PropertyTable; + +import java.util.List; + +/** + * Implementation of {@link PropertyEditorPresentation} that contains zero or more other + * {@link PropertyEditorPresentation}'s. + * + * @author scheglov_ke + * @coverage core.model.property.editor + */ +public class CompoundPropertyEditorPresentation extends PropertyEditorPresentation { + private final List<PropertyEditorPresentation> m_presentations = Lists.newArrayList(); + + //////////////////////////////////////////////////////////////////////////// + // + // Access + // + //////////////////////////////////////////////////////////////////////////// + /** + * Adds child {@link PropertyEditorPresentation}.<br> + * Child {@link PropertyEditorPresentation}'s are displayed from right to left. + */ + public void add(PropertyEditorPresentation presentation) { + m_presentations.add(presentation); + } + + //////////////////////////////////////////////////////////////////////////// + // + // PropertyEditorPresentation + // + //////////////////////////////////////////////////////////////////////////// + @Override + public int show(PropertyTable propertyTable, + Property property, + int x, + int y, + int width, + int height) { + int sumWidth = 0; + for (PropertyEditorPresentation presentation : m_presentations) { + int presentationWidth = presentation.show(propertyTable, property, x, y, width, height); + sumWidth += presentationWidth; + width -= presentationWidth; + } + return sumWidth; + } + + @Override + public void hide(PropertyTable propertyTable, Property property) { + for (PropertyEditorPresentation presentation : m_presentations) { + presentation.hide(propertyTable, property); + } + } +} |