Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-02-13 16:38:52 +0000
committerGerrit Code Review @ Eclipse.org2015-02-13 16:38:53 +0000
commit2acfaac478b7088dd7c0005acfeb59b04366be67 (patch)
tree05a507c694d7998ddd2d998a450dc6292c66a2e3 /plugins/infra/core
parentb29af0c8ca3663dae3a8bff6b396d21322b88ee7 (diff)
parentbc8000e78a29f0588310ea8e390a02099db3e8f2 (diff)
downloadorg.eclipse.papyrus-2acfaac478b7088dd7c0005acfeb59b04366be67.tar.gz
org.eclipse.papyrus-2acfaac478b7088dd7c0005acfeb59b04366be67.tar.xz
org.eclipse.papyrus-2acfaac478b7088dd7c0005acfeb59b04366be67.zip
Merge "Bug 444335 - [Diagram Templates] Keep the opened diagrams while using a template to create a model - add the tabfoleder selection of the template to the one initialized with the wizard selection"
Diffstat (limited to 'plugins/infra/core')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java395
1 files changed, 206 insertions, 189 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java
index ae9898f4304..b0af49b61c9 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java
@@ -1,189 +1,206 @@
-/*****************************************************************************
- * 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
- * Emilien Perico emilien.perico@atosorigin.com - add methods to manage di resource
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.core.sashwindows.di.util;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory;
-import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
-import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel;
-import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
-import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
-import org.eclipse.papyrus.infra.core.sashwindows.di.Window;
-import org.eclipse.papyrus.infra.core.sashwindows.di.exception.SashEditorException;
-
-
-/**
- * Set of utility methods
- *
- * @author dumoulin
- */
-public class DiUtils {
-
- /**
- * Create a default SashModel with one window and one folder.
- * Set the current folder.
- *
- * @param diResource
- * @return
- */
- static public SashModel createDefaultSashModel() {
-
- // SashModel
- SashModel sashModel = DiFactory.eINSTANCE.createSashModel();
- Window window = DiFactory.eINSTANCE.createWindow();
- sashModel.getWindows().add(window);
-
- TabFolder folder = DiFactory.eINSTANCE.createTabFolder();
- window.setPanel(folder);
- // Default folder
- sashModel.setCurrentSelectionSilently(folder);
-
- return sashModel;
- }
-
- /**
- * Create a default SashWindowsMngr with one PageLit and one default SashModel.
- * Set the current folder.
- *
- * @param diResource
- * @return
- */
- static public SashWindowsMngr createDefaultSashWindowsMngr() {
- SashWindowsMngr model;
-
- model = DiFactory.eINSTANCE.createSashWindowsMngr();
-
- // SashModel
- SashModel layout = createDefaultSashModel();
-
- model.setSashModel(layout);
- return model;
- }
-
- /**
- * Lookup for the SashModel object in the resource.
- *
- * @param diResource
- * @return The {@link DiSashModel} or null if not found.
- */
- static public SashWindowsMngr lookupSashWindowsMngr(Resource diResource) {
-
- for (Object node : diResource.getContents()) {
- if (node instanceof SashWindowsMngr) {
- return (SashWindowsMngr) node;
- }
- }
- return null;
- }
-
- /**
- * Gets the page reference of the specified eObject
- *
- * @param diResource
- * @param eObject
- *
- * @return the page ref of eObject, null if not found
- * TODO This method use too low level mechanism for its implementation. Consider to move it in a
- * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
- * instead ?
- *
- * @deprecated Should use IPageMngr instead.
- */
- @Deprecated
- static public PageRef getPageRef(Resource diResource, EObject eObject) {
- SashWindowsMngr windowsMngr = lookupSashWindowsMngr(diResource);
- if (windowsMngr != null && windowsMngr.getPageList() != null) {
-
- for (PageRef pageRef : windowsMngr.getPageList().getAvailablePage()) {
-
- EObject emfPageIdentifier = pageRef.getEmfPageIdentifier();
- if (eObject != null && eObject.equals(emfPageIdentifier)) {
- return pageRef;
- }
- }
- }
- return null;
- }
-
- /**
- * Adds page to the page list of the sash windows manager
- *
- * @param diResource
- * @param pageRef
- * @throws SashEditorException
- * TODO This method use too low level mechanism for its implementation. Consider to move it in a
- * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
- * instead ?
- * @deprecated Should use IPageMngr instead.
- */
- @Deprecated
- static public void addPageToPageList(Resource diResource, PageRef pageRef) throws SashEditorException {
- // Do nothing. The page list is not used anymore
- }
-
- /**
- * Adds page to the page list of the sash windows manager.
- *
- * @param pageRef
- * @param windowsMngr
- * @throws SashEditorException
- * TODO This method use too low level mechanism for its implementation. Consider to move it in a
- * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
- * instead ?
- *
- * @deprecated Should use IPageMngr instead.
- */
- @Deprecated
- static public void addPageToPageList(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException {
- // Do nothing. The page list is not used anymore
- }
-
- /**
- * Adds page to tab folder.
- *
- * @param windowsMngr
- * @param pageRef
- * @throws SashEditorException
- * TODO This method use too low level mechanism for its implementation. Consider to move it in a
- * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
- * instead ?
- *
- * @deprecated Should use IPageMngr instead.
- */
- @Deprecated
- static public void addPageToTabFolder(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException {
-
- // Check parameters
- if (pageRef == null || pageRef.getPageIdentifier() == null) {
- throw new SashEditorException("Unable to add the page to the tab folder: parameters are null");
- }
-
- SashModel sashModel = windowsMngr.getSashModel();
- if (sashModel == null) {
- throw new SashEditorException("Unable to add the page to the tab folder: can't find SashModel");
- }
-
- // Get the currently active folder in order to add the page.
- TabFolder tabFolder = sashModel.getCurrentSelection();
- if (tabFolder == null) {
- throw new SashEditorException("Unable to add the page to the tab folder: No active folder");
- }
-
- tabFolder.addPage(pageRef.getPageIdentifier());
- }
-
-}
+/*****************************************************************************
+ * 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
+ * Emilien Perico emilien.perico@atosorigin.com - add methods to manage di resource
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sashwindows.di.util;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
+import org.eclipse.papyrus.infra.core.sashwindows.di.Window;
+import org.eclipse.papyrus.infra.core.sashwindows.di.exception.SashEditorException;
+
+
+/**
+ * Set of utility methods
+ *
+ * @author dumoulin
+ */
+public class DiUtils {
+
+ /**
+ * Create a default SashModel with one window and one folder.
+ * Set the current folder.
+ *
+ * @param diResource
+ * @return
+ */
+ static public SashModel createDefaultSashModel() {
+
+ // SashModel
+ SashModel sashModel = DiFactory.eINSTANCE.createSashModel();
+ Window window = DiFactory.eINSTANCE.createWindow();
+ sashModel.getWindows().add(window);
+
+ TabFolder folder = DiFactory.eINSTANCE.createTabFolder();
+ window.setPanel(folder);
+ // Default folder
+ sashModel.setCurrentSelectionSilently(folder);
+
+ return sashModel;
+ }
+
+ /**
+ * Create a default SashWindowsMngr with one PageLit and one default SashModel.
+ * Set the current folder.
+ *
+ * @param diResource
+ * @return
+ */
+ static public SashWindowsMngr createDefaultSashWindowsMngr() {
+ SashWindowsMngr model;
+
+ model = DiFactory.eINSTANCE.createSashWindowsMngr();
+
+ // SashModel
+ SashModel layout = createDefaultSashModel();
+
+ model.setSashModel(layout);
+ return model;
+ }
+
+ /**
+ * Lookup for the SashModel object in the resource.
+ *
+ * @param diResource
+ * @return The {@link DiSashModel} or null if not found.
+ */
+ static public SashWindowsMngr lookupSashWindowsMngr(Resource diResource) {
+
+ for (Object node : diResource.getContents()) {
+ if (node instanceof SashWindowsMngr) {
+ return (SashWindowsMngr) node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Lookup for the current selection TabFolder object in the resource.
+ *
+ * @param diResource
+ * @return The {@link TabFolder} or null if not found.
+ */
+ static public TabFolder lookupCurrentTabFolderSelection(Resource diResource) {
+ SashWindowsMngr lookupSashWindowsMngr = lookupSashWindowsMngr(diResource);
+ if (lookupSashWindowsMngr != null){
+ SashModel sashModel = lookupSashWindowsMngr.getSashModel();
+ if (sashModel != null){
+ return sashModel.getCurrentSelection();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets the page reference of the specified eObject
+ *
+ * @param diResource
+ * @param eObject
+ *
+ * @return the page ref of eObject, null if not found
+ * TODO This method use too low level mechanism for its implementation. Consider to move it in a
+ * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
+ * instead ?
+ *
+ * @deprecated Should use IPageMngr instead.
+ */
+ @Deprecated
+ static public PageRef getPageRef(Resource diResource, EObject eObject) {
+ SashWindowsMngr windowsMngr = lookupSashWindowsMngr(diResource);
+ if (windowsMngr != null && windowsMngr.getPageList() != null) {
+
+ for (PageRef pageRef : windowsMngr.getPageList().getAvailablePage()) {
+
+ EObject emfPageIdentifier = pageRef.getEmfPageIdentifier();
+ if (eObject != null && eObject.equals(emfPageIdentifier)) {
+ return pageRef;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds page to the page list of the sash windows manager
+ *
+ * @param diResource
+ * @param pageRef
+ * @throws SashEditorException
+ * TODO This method use too low level mechanism for its implementation. Consider to move it in a
+ * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
+ * instead ?
+ * @deprecated Should use IPageMngr instead.
+ */
+ @Deprecated
+ static public void addPageToPageList(Resource diResource, PageRef pageRef) throws SashEditorException {
+ // Do nothing. The page list is not used anymore
+ }
+
+ /**
+ * Adds page to the page list of the sash windows manager.
+ *
+ * @param pageRef
+ * @param windowsMngr
+ * @throws SashEditorException
+ * TODO This method use too low level mechanism for its implementation. Consider to move it in a
+ * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
+ * instead ?
+ *
+ * @deprecated Should use IPageMngr instead.
+ */
+ @Deprecated
+ static public void addPageToPageList(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException {
+ // Do nothing. The page list is not used anymore
+ }
+
+ /**
+ * Adds page to tab folder.
+ *
+ * @param windowsMngr
+ * @param pageRef
+ * @throws SashEditorException
+ * TODO This method use too low level mechanism for its implementation. Consider to move it in a
+ * more appropriate class. Furthermore, some similar methods already exist. Can't we use them
+ * instead ?
+ *
+ * @deprecated Should use IPageMngr instead.
+ */
+ @Deprecated
+ static public void addPageToTabFolder(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException {
+
+ // Check parameters
+ if (pageRef == null || pageRef.getPageIdentifier() == null) {
+ throw new SashEditorException("Unable to add the page to the tab folder: parameters are null");
+ }
+
+ SashModel sashModel = windowsMngr.getSashModel();
+ if (sashModel == null) {
+ throw new SashEditorException("Unable to add the page to the tab folder: can't find SashModel");
+ }
+
+ // Get the currently active folder in order to add the page.
+ TabFolder tabFolder = sashModel.getCurrentSelection();
+ if (tabFolder == null) {
+ throw new SashEditorException("Unable to add the page to the tab folder: No active folder");
+ }
+
+ tabFolder.addPage(pageRef.getPageIdentifier());
+ }
+
+}

Back to the top