Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java11
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java93
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java352
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java14
4 files changed, 254 insertions, 216 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java
index 51325de63ad..1138658c52d 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java
@@ -93,4 +93,15 @@ public class SashPanelModel implements IAbstractPanelModel, ISashPanelModel {
return sashPanel.getSashPosition();
}
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getSashInitialPosition()
+ *
+ * @return
+ */
+ @Override
+ public int getSashInitialPosition() {
+ int pos = (int) (sashPanel.getSashPosition()*100);
+ return pos;
+ }
+
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java
index 0eacac2636b..910b5f2e237 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java
@@ -1,41 +1,52 @@
-package org.eclipse.papyrus.infra.core.sasheditor.contentprovider;
-
-import java.util.List;
-
-import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
-
-/**
- * This is the model for a Sash widget. A Sash contains two children (of type Sash or Folder)
- * separated by a sash. The sash can be moved, resizing the children.
- * This interface is used to specify that a sash with two children should be drawn.
- *
- * @author cedric dumoulin
- *
- */
-public interface ISashPanelModel extends IAbstractPanelModel {
-
- /**
- * Get the list of children that should be displayed in the folder.
- * Children can be Panel (ie Sash or Folder)
- *
- * @return
- */
- public List</* Panel */?> getChildren();
-
- /**
- * Create the Interface used to access the real model.
- * This method is called by the {@link SashWindowsContainer} to get the interface.
- * The method is called only once for a given object.
- *
- * @param child
- * A child representing a panel and returned by getChildren().
- * @return
- */
- public IAbstractPanelModel createChildSashModel(/* Panel */Object child);
-
- /**
- * Get the sash direction. Can be SWT.VERTICAL or SWT.HORIZONTAL.
- */
- public int getSashDirection();
-
-}
+package org.eclipse.papyrus.infra.core.sasheditor.contentprovider;
+
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
+
+/**
+ * This is the model for a Sash widget. A Sash contains two children (of type Sash or Folder)
+ * separated by a sash. The sash can be moved, resizing the children.
+ * This interface is used to specify that a sash with two children should be drawn.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public interface ISashPanelModel extends IAbstractPanelModel {
+
+ /**
+ * Get the list of children that should be displayed in the folder.
+ * Children can be Panel (ie Sash or Folder)
+ *
+ * @return
+ */
+ public List</* Panel */?> getChildren();
+
+ /**
+ * Create the Interface used to access the real model.
+ * This method is called by the {@link SashWindowsContainer} to get the interface.
+ * The method is called only once for a given object.
+ *
+ * @param child
+ * A child representing a panel and returned by getChildren().
+ * @return
+ */
+ public IAbstractPanelModel createChildSashModel(/* Panel */Object child);
+
+ /**
+ * Get the sash direction. Can be SWT.VERTICAL or SWT.HORIZONTAL.
+ */
+ public int getSashDirection();
+
+ /**
+ * Get the initial position of the Sash, in percent. This position is used to set the sash when a new part is created.
+ * The value is betwenn 1 and 100 (percent).
+ * A value of 0 mean that the sash should separate both part equaly (in the middle)
+ *
+ * @return A value between 0 and 100.
+ *
+ * @since 2.0
+ */
+
+ public int getSashInitialPosition();
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java
index 6c7d0411bfa..f5e4c8d01a6 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java
@@ -1,170 +1,182 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA LIST & LIFL
- *
- *
- * 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel;
-
-
-/**
- * Simple implementation of the {@link ISashPanelModel}.
- *
- * @author dumoulin
- */
-public class SashPanelModel extends AbstractPanelModel implements ISashPanelModel {
-
- /** Ordered set of childs (a left and right child, or upper and lower) */
- protected AbstractPanelModel[] children = new AbstractPanelModel[2];
-
- // The children array as a list
- protected List<AbstractPanelModel> childrenList = Arrays.asList(children);
-
- protected int sashDirection;
-
-
-
- /**
- * @param children
- * @param sashDirection
- */
- public SashPanelModel(AbstractModel parent, AbstractPanelModel leftChild, AbstractPanelModel rightChild, int sashDirection) {
- super(parent);
- this.children[0] = leftChild;
- this.children[1] = rightChild;
-
- this.sashDirection = sashDirection;
- }
-
-
- /**
- * Set the left child.
- *
- * @param child
- */
- public void setLeftChild(AbstractPanelModel child) {
- this.children[0] = child;
- }
-
- /**
- * Get the left child
- *
- * @return
- */
- private AbstractPanelModel getLeftChild() {
- return children[0];
- }
-
- /**
- * Set the left child.
- *
- * @param child
- */
- public void setRightChild(AbstractPanelModel child) {
- this.children[1] = child;
- }
-
- /**
- * Get the right child
- *
- * @return
- */
- private AbstractPanelModel getRightChild() {
- return children[1];
- }
-
-
-
- /**
- * Create the SashPanelModel from the raw model.
- * In this implementation, the rawModel is the SashPanelModel.
- * This default implementation return directly the child which is already of the appropriate type.
- */
- @Override
- public IAbstractPanelModel createChildSashModel(Object rawModel) {
- return (IAbstractPanelModel) rawModel;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<?> getChildren() {
- return childrenList;
- }
-
- /**
- * Return the direction of the sash:
- *
- */
- @Override
- public int getSashDirection() {
- return sashDirection;
- }
-
- /**
- * Replace specified child with the new child. {@inheritDoc}
- */
- @Override
- public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) {
-
-
- if (getLeftChild() == oldChild) {
- setLeftChild(newChild);
- } else if (getRightChild() == oldChild) {
- setRightChild(newChild);
- }
-
- }
-
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- protected TabFolderModel lookupTabFolder(IPageModel tabItem) {
- TabFolderModel parent = getLeftChild().lookupTabFolder(tabItem);
- if (parent != null) {
- return parent;
- }
-
- return getRightChild().lookupTabFolder(tabItem);
- }
-
-
- /**
- * Delete the sashModel.
- * The childToDelete is removed from the tree, bypass the sashnode : the other child parent is set to sashnode parent.
- *
- * @param tabFolder
- */
- protected void delete(AbstractPanelModel childToDelete) {
-
- // Get the other child
- AbstractPanelModel otherChild = (childToDelete == getLeftChild() ? getRightChild() : getLeftChild());
-
- AbstractModel parent = getParent();
- // Change parent
- otherChild.setParent(parent);
- parent.replaceChild(this, otherChild);
-
-
- }
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2009 CEA LIST & LIFL
+ *
+ *
+ * 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel;
+
+
+/**
+ * Simple implementation of the {@link ISashPanelModel}.
+ *
+ * @author dumoulin
+ */
+public class SashPanelModel extends AbstractPanelModel implements ISashPanelModel {
+
+ /** Ordered set of childs (a left and right child, or upper and lower) */
+ protected AbstractPanelModel[] children = new AbstractPanelModel[2];
+
+ // The children array as a list
+ protected List<AbstractPanelModel> childrenList = Arrays.asList(children);
+
+ protected int sashDirection;
+
+
+
+ /**
+ * @param children
+ * @param sashDirection
+ */
+ public SashPanelModel(AbstractModel parent, AbstractPanelModel leftChild, AbstractPanelModel rightChild, int sashDirection) {
+ super(parent);
+ this.children[0] = leftChild;
+ this.children[1] = rightChild;
+
+ this.sashDirection = sashDirection;
+ }
+
+
+ /**
+ * Set the left child.
+ *
+ * @param child
+ */
+ public void setLeftChild(AbstractPanelModel child) {
+ this.children[0] = child;
+ }
+
+ /**
+ * Get the left child
+ *
+ * @return
+ */
+ private AbstractPanelModel getLeftChild() {
+ return children[0];
+ }
+
+ /**
+ * Set the left child.
+ *
+ * @param child
+ */
+ public void setRightChild(AbstractPanelModel child) {
+ this.children[1] = child;
+ }
+
+ /**
+ * Get the right child
+ *
+ * @return
+ */
+ private AbstractPanelModel getRightChild() {
+ return children[1];
+ }
+
+
+
+ /**
+ * Create the SashPanelModel from the raw model.
+ * In this implementation, the rawModel is the SashPanelModel.
+ * This default implementation return directly the child which is already of the appropriate type.
+ */
+ @Override
+ public IAbstractPanelModel createChildSashModel(Object rawModel) {
+ return (IAbstractPanelModel) rawModel;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<?> getChildren() {
+ return childrenList;
+ }
+
+ /**
+ * Return the direction of the sash:
+ *
+ */
+ @Override
+ public int getSashDirection() {
+ return sashDirection;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getSashInitialPosition()
+ *
+ * @return 0;
+ */
+ @Override
+ public int getSashInitialPosition() {
+ return 0;
+ }
+
+
+ /**
+ * Replace specified child with the new child. {@inheritDoc}
+ */
+ @Override
+ public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) {
+
+
+ if (getLeftChild() == oldChild) {
+ setLeftChild(newChild);
+ } else if (getRightChild() == oldChild) {
+ setRightChild(newChild);
+ }
+
+ }
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ protected TabFolderModel lookupTabFolder(IPageModel tabItem) {
+ TabFolderModel parent = getLeftChild().lookupTabFolder(tabItem);
+ if (parent != null) {
+ return parent;
+ }
+
+ return getRightChild().lookupTabFolder(tabItem);
+ }
+
+
+ /**
+ * Delete the sashModel.
+ * The childToDelete is removed from the tree, bypass the sashnode : the other child parent is set to sashnode parent.
+ *
+ * @param tabFolder
+ */
+ protected void delete(AbstractPanelModel childToDelete) {
+
+ // Get the other child
+ AbstractPanelModel otherChild = (childToDelete == getLeftChild() ? getRightChild() : getLeftChild());
+
+ AbstractModel parent = getParent();
+ // Change parent
+ otherChild.setParent(parent);
+ parent.replaceChild(this, otherChild);
+
+
+ }
+
+
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java
index c664ca5d738..6e3f00f37e1 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java
@@ -112,11 +112,15 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent {
container = new ReplaceableSashForm(parent, sashDirection);
// Set weight
- float sashPosition = (float) 0.7;
- int firstSize = (int) (sashPosition*100);
- int secondSize = 100-firstSize;
- int[] weights = {firstSize,secondSize};
- container.setWeights(weights);
+
+ int sashPosition = model.getSashInitialPosition();
+ if( sashPosition >0 && sashPosition <101 ) {
+ // Use initial position
+ int firstSize = (int) (sashPosition);
+ int secondSize = 100-firstSize;
+ int[] weights = {firstSize,secondSize};
+ container.setWeights(weights);
+ }
}
/**

Back to the top