From 18ba80f6021431bbeb6a8b99fc458e20270f925c Mon Sep 17 00:00:00 2001 From: cdumoulin Date: Mon, 6 Feb 2012 17:22:14 +0000 Subject: 273413: [Usability][Navigation] Papyrus shall enable diagram navigation history with back and next buttons https://bugs.eclipse.org/bugs/show_bug.cgi?id=273413 Rollback to version 5569 keep commit 5750 bug 348689 keep refactoring Remove all code related to navigation history --- .../contentprovider/IAbstractPanelModel.java | 5 +- .../contentprovider/IContentChangedListener.java | 16 +- .../contentprovider/IContentChangedProvider.java | 8 +- .../sasheditor/contentprovider/IEditorModel.java | 7 +- .../core/sasheditor/contentprovider/IPageMngr.java | 49 +- .../sasheditor/contentprovider/IPageModel.java | 11 +- .../contentprovider/ISashPanelModel.java | 11 +- .../ISashWindowsContentProvider.java | 67 +- .../contentprovider/ITabFolderModel.java | 10 +- .../contentprovider/simple/AbstractModel.java | 3 + .../contentprovider/simple/AbstractPanelModel.java | 5 + .../contentprovider/simple/SashPanelModel.java | 21 +- .../simple/SimpleSashWindowsContentProvider.java | 67 +- .../contentprovider/simple/TabFolderModel.java | 27 +- .../singlefolder/SingleFolderContentProvider.java | 11 +- .../singlefolder/SingleFolderModel.java | 11 +- .../editor/AbstractMultiPageSashEditor.java | 71 +- .../core/sasheditor/editor/IComponentPage.java | 9 +- .../infra/core/sasheditor/editor/IEditorPage.java | 9 +- .../sasheditor/editor/IMultiPageEditorPart.java | 8 +- .../infra/core/sasheditor/editor/IPage.java | 11 +- .../sasheditor/editor/IPageChangedListener.java | 2 + .../infra/core/sasheditor/editor/IPageVisitor.java | 3 + .../sasheditor/editor/ISashWindowsContainer.java | 32 +- .../ISashWindowsContainerChangedListener.java | 2 + .../editor/SashTabDecorationSynchronizer.java | 122 +-- .../editor/SashWindowsEventsProvider.java | 88 +- .../ComposedActionBarContributor.java | 83 +- .../IMultiPageEditorActionBarContributor.java | 14 +- .../MultiPageEditorActionBarContributor.java | 10 +- .../editor/gef/MultiDiagramEditorGefDelegate.java | 42 +- .../sasheditor/internal/AbstractPanelPart.java | 32 +- .../core/sasheditor/internal/AbstractPart.java | 11 +- .../internal/ActiveEditorServicesSwitcher.java | 64 +- .../sasheditor/internal/ActivePageTracker.java | 23 +- .../core/sasheditor/internal/ComponentPart.java | 85 +- .../infra/core/sasheditor/internal/Copyright.java | 1 + .../sasheditor/internal/IMultiEditorManager.java | 25 +- .../core/sasheditor/internal/IPanelParent.java | 7 +- .../core/sasheditor/internal/IPartVisitor.java | 24 +- .../LookupFolderPartByRawModelVisitor.java | 3 + .../internal/LookupIPageByIEditorPartVisitor.java | 2 + .../internal/LookupModelPageVisitor.java | 2 + .../sasheditor/internal/NotFoundException.java | 2 + .../infra/core/sasheditor/internal/PTabFolder.java | 80 +- .../infra/core/sasheditor/internal/PagePart.java | 52 +- .../sasheditor/internal/PageVisitorWrapper.java | 1 + .../infra/core/sasheditor/internal/PartLists.java | 25 +- .../core/sasheditor/internal/PartVisitor.java | 4 + .../infra/core/sasheditor/internal/RootPart.java | 90 +- .../internal/SashContainerEventsListener.java | 62 ++ .../internal/SashContainerEventsProvider.java | 15 +- .../core/sasheditor/internal/SashPanelPart.java | 86 +- .../sasheditor/internal/SashWindowsContainer.java | 1003 ++++++++++++++++++++ .../sasheditor/internal/SashWindowsException.java | 1 + .../sasheditor/internal/ShowPartStatusVisitor.java | 17 +- .../core/sasheditor/internal/TabFolderPart.java | 416 ++++---- .../core/sasheditor/internal/TabItemPart.java | 44 +- .../eclipsecopy/AbstractTabFolderPart.java | 420 ++++---- .../eclipsecopy/MultiPageSelectionProvider.java | 34 +- .../multipage/editor/MultiPageEditor.java | 113 +-- 61 files changed, 2304 insertions(+), 1275 deletions(-) create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainer.java (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src') diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java index 09e99acb271..93e77336ac7 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java @@ -4,12 +4,13 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; /** - * A Panel represent a SashPanel or a TabFolder. This interface is the common - * ancestor of the Panel models used in sash system. + * A Panel represent a SashPanel or a TabFolder. + * This interface is the common ancestor of the Panel models used in sash system. * * @author dumoulin * */ public abstract interface IAbstractPanelModel { + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java index aa94ebacea2..1c967e113f3 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java @@ -3,19 +3,20 @@ */ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + /** - * Interface to be implemented by classes needing to be notified when the - * SashContent model has changed. This interface is not used by the - * sashesWindows itself. It exists to allows ContentProvider implementation to - * provide a common notification mechanism. + * Interface to be implemented by classes needing to be notified + * when the SashContent model has changed. + * This interface is not used by the sashesWindows itself. It exists to allows ContentProvider + * implementation to provide a common notification mechanism. * * @author dumoulin */ public interface IContentChangedListener { /** - * Event indicating the change. TODO The types are not set correctly from - * user like DI model. But anyway there aren't used by clients. + * Event indicating the change. + * TODO The types are not set correctly from user like DI model. But anyway there aren't used by clients. * * @author dumoulin */ @@ -49,6 +50,7 @@ public interface IContentChangedListener { this.object = object; } + /** * @return the type */ @@ -56,6 +58,7 @@ public interface IContentChangedListener { return type; } + /** * @return the model */ @@ -63,6 +66,7 @@ public interface IContentChangedListener { return model; } + /** * @return the object */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java index f286b3afc54..656ea9e93b0 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java @@ -1,9 +1,11 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + /** - * Interface implemented by classes firing events when the ContentProvider - * content change. This interface can be used by client of ContentProvider. It - * is not use directly by the SashSystem. + * Interface implemented by classes firing events when the ContentProvider content + * change. + * This interface can be used by client of ContentProvider. + * It is not use directly by the SashSystem. * * @author dumoulin */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java index d0af56907a0..15818dab2f8 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java @@ -26,16 +26,15 @@ import org.eclipse.ui.part.EditorActionBarContributor; public interface IEditorModel extends IPageModel { /** - * Create the IEditor that should be shown. Editor life cycle methods are - * not called. + * Create the IEditor that should be shown. + * Editor life cycle methods are not called. * * @return A new instance of the IEditor. */ public IEditorPart createIEditorPart() throws PartInitException; /** - * Get the EditorActionBarContributor that should be associated with the - * editor . + * Get the EditorActionBarContributor that should be associated with the editor . * * @return */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java index 2e7511f8dfb..a408bb70a27 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java @@ -9,7 +9,6 @@ * * Contributors: * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Anass Radouani (Atos) - Add History management * *****************************************************************************/ @@ -17,31 +16,29 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; import java.util.List; -import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashContainerEventsListener; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; + /** - * Interface providing method to manage pages in the Sash Windows system. This - * interface can be provided by ContentProvider whishing to provide a standard - * way to manage pages. This interface is not mandatory for the Sasheditor. This - * interface provide basic access to the Sash Windows system. It is intended to - * be used from the application in order to interact with the ContentProvider. - * Then, the {@link SashWindowsContainer} will refresh its views. + * Interface providing method to manage pages in the Sash Windows system. + * This interface can be provided by ContentProvider whishing to provide a standard + * way to manage pages. This interface is not mandatory for the Sasheditor. + * This interface provide basic access to the Sash Windows system. + * It is intended to be used from the application in order to interact with the ContentProvider. Then, + * the {@link SashWindowsContainer} will refresh its views. * * * @author dumoulin */ -public interface IPageMngr extends IPageChangedListener, SashContainerEventsListener { +public interface IPageMngr { /** * Add a Page identifier to the list of pages, do not open it. * * @param page - * The object identifying the page to add. This object will be - * passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This - * identifier is stored in the sash model. It should be a - * reference on a EMF object identifying the page. + * The object identifying the page to add. This object will be passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This + * identifier is stored in the sash model. + * It should be a reference on a EMF object identifying the page. */ public void addPage(Object pageIdentifier); @@ -55,14 +52,15 @@ public interface IPageMngr extends IPageChangedListener, SashContainerEventsList public void removePage(Object pageIdentifier); /** - * Close the page corresponding to the identifier. The identifier is removed - * from the Sash Windows, but not from the list of pages. + * Close the page corresponding to the identifier. + * The identifier is removed from the Sash Windows, but not from the list of pages. * * @param pageIdentifier * The object identifying the page */ public void closePage(Object pageIdentifier); + /** * Close all opened pages. * @@ -77,16 +75,16 @@ public interface IPageMngr extends IPageChangedListener, SashContainerEventsList public void closeOtherPages(Object pageIdentifier); /** - * Open a Page corresponding to the identifier. If the page is not in the - * list of pages, add it. The identifier is first added to the current - * folder model. Then the Sash Windows should react and ask the {@link IPageModelFactory} to create the IPageModel. This later is then - * used to create the SWT page. If + * Open a Page corresponding to the identifier. If the page is not in the list of pages, add it. + * The identifier is first added to the current folder model. Then the Sash Windows should react and + * ask the {@link IPageModelFactory} to create the IPageModel. This later is then used to create the + * SWT page. + * If * * @param page - * The object identifying the page to add. This object will be - * passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This - * identifier is stored in the sash model. It should be a - * reference on a EMF object identifying the page. + * The object identifying the page to add. This object will be passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This + * identifier is stored in the sash model. + * It should be a reference on a EMF object identifying the page. */ public void openPage(Object pageIdentifier); @@ -105,5 +103,4 @@ public interface IPageMngr extends IPageChangedListener, SashContainerEventsList */ public boolean isOpen(Object pageIdentifier); - } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java index 98739beaf17..9076761efb6 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java @@ -7,9 +7,10 @@ import org.eclipse.swt.graphics.Image; /** * This interface is the root of the hierarchy of models representing Pages. - * This represent the final element shown in the sashes window. It can be an - * Editor or a simple control. This interface is used by the sashes window to - * interact with the model describing the element to be shown in the TabItem. + * This represent the final element shown in the sashes window. + * It can be an Editor or a simple control. + * This interface is used by the sashes window to interact with the model describing the element to be + * shown in the TabItem. * * @author dumoulin * @@ -31,8 +32,8 @@ public abstract interface IPageModel { public Image getTabIcon(); /** - * Get the raw model corresponding to this node. This is the object provided - * to {@link ITabFolderModel.getChildren()} + * Get the raw model corresponding to this node. + * This is the object provided to {@link ITabFolderModel.getChildren()} * * @return */ 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 af353c760b8..982f9d3ba0c 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 @@ -3,9 +3,8 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; import java.util.List; /** - * A sash node contains two children 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. + * A sash node contains two children 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 dumoulin * @@ -20,9 +19,9 @@ public interface ISashPanelModel extends IAbstractPanelModel { public List getChildren(); /** - * Create the Interface used to access the real model. This method is called - * by the sashes window to get the interface. The method is called only once - * for a given object. + * Create the Interface used to access the real model. + * This method is called by the sashes window to get the interface. + * The method is called only once for a given object. * * @param child * A child returned by getChildren(). diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java index eb8c17206b6..72930fe979e 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java @@ -1,12 +1,12 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; /** - * This interface is used by the sash windows system to discover its content. It - * is considered as the root of the sash windows models. The sashsystem is able - * to retrieve all its content from this interface, and associated interfaces {@link ITabFolderModel}, {@link ISashPanelModel}, {@link IPageModel}. - * The - * interface is also used by the sashsystem to communicate, by sending event, - * with the effective implementation or upper level. + * This interface is used by the sash windows system to discover its content. It is considered + * as the root of the sash windows models. + * The sashsystem is able to retrieve all its content from this interface, and associated interfaces {@link ITabFolderModel}, {@link ISashPanelModel}, + * {@link IPageModel}. + * The interface is also used by the sashsystem to communicate, by sending event, with the + * effective implementation or upper level. * * @author dumoulin * @@ -14,10 +14,10 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; public interface ISashWindowsContentProvider { /** - * Get the root object shown in the sashes window. The type of the returned - * object is left to the implementation. The sashes window will ask for an - * interface used to interact with the object. In normal implementation, - * this method should return the model used by the implementation. + * Get the root object shown in the sashes window. + * The type of the returned object is left to the implementation. + * The sashes window will ask for an interface used to interact with the object. + * In normal implementation, this method should return the model used by the implementation. * * @return The object representing the root of the sashes window. */ @@ -25,8 +25,8 @@ public interface ISashWindowsContentProvider { /** * create the interface used by the sashes window to access the root model. - * This method is called by the sashes window to get the interface. The - * method is called only once for a given object. + * This method is called by the sashes window to get the interface. + * The method is called only once for a given object. * * @param root * @return The SashModel corresponding to the specified root object. @@ -34,12 +34,12 @@ public interface ISashWindowsContentProvider { public IAbstractPanelModel createChildSashModel(Object root); /** - * Add a page to the current TabFolder. The Page is added at the end of the - * tab list. + * Add a page to the current TabFolder. + * The Page is added at the end of the tab list. * * @param page - * An object identifying the page to add. The object could be - * anything. It will be passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. + * An object identifying the page to add. The object could be anything. It will be + * passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. */ public void addPage(Object page); @@ -47,8 +47,8 @@ public interface ISashWindowsContentProvider { * Add a page at the specified index of TabFolder. * * @param page - * An object identifying the page to add. The object could be - * anything. It will be passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. + * An object identifying the page to add. The object could be anything. It will be + * passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. * @param index * Index to where the tabItem should be added. */ @@ -81,8 +81,8 @@ public interface ISashWindowsContentProvider { public void removePage(int index); /** - * Remove the page from the sashes window. Look for the folder containing - * the page. + * Remove the page from the sashes window. + * Look for the folder containing the page. * * @param page * The Object identifying the page. This is the object used in {@link #addPage(Object)}. @@ -97,11 +97,11 @@ public interface ISashWindowsContentProvider { public void removePage(ITabFolderModel parentFolder, int tabIndex); /** - * Ask the model to move the specified tab to the specified side of the - * specified targetFolder. This method is called by the the - * SashTileContainer when the user have drag a tab in a correct place. The - * SashTileContainer has not change is presentation yet. This will be done - * when the corresponding event will occur. + * Ask the model to move the specified tab to the specified side of the specified targetFolder. + * This method + * is called by the the SashTileContainer when the user + * have drag a tab in a correct place. The SashTileContainer has not change is presentation yet. This + * will be done when the corresponding event will occur. * * @param tabFolder * The folder containing the tab to move @@ -110,22 +110,21 @@ public interface ISashWindowsContentProvider { * @param targetFolder * The folder to which the side refer to * @param side - * Side where node should be inserted : SWT.LEFT, SWT.RIGHT, - * SWT.TOP, SWT.DOWN. + * Side where node should be inserted : SWT.LEFT, SWT.RIGHT, SWT.TOP, SWT.DOWN. */ public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side); /** - * Ask the model to keep trace of the Current Folder. The notion of Current - * Folder is used by {@link #addPage(Object)}. Calling this method should - * not fire a Change Event. + * Ask the model to keep trace of the Current Folder. + * The notion of Current Folder is used by {@link #addPage(Object)}. + * Calling this method should not fire a Change Event. * - * This method is used by the SashSystem when the user select a new folder - * by clicking on one of the tabs. + * This method is used by the SashSystem when the user select a new folder by clicking on one of + * the tabs. * * @param rawModel - * The Raw model identifying the folder. This is the same object - * as the one returned by {@link ISashPanelModel#getChildren()} when the child denote a folder. + * The Raw model identifying the folder. This is the same object as the one + * returned by {@link ISashPanelModel#getChildren()} when the child denote a folder. */ public void setCurrentFolder(Object rawModel); diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java index c1238b958f1..fe210fa33fb 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java @@ -3,8 +3,8 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; import java.util.List; /** - * A folder containing tabItem. This interface is used to specify that a - * TabFolder should be drawn. + * A folder containing tabItem. + * This interface is used to specify that a TabFolder should be drawn. * * @author dumoulin * @@ -22,9 +22,9 @@ public interface ITabFolderModel extends IAbstractPanelModel { public List getChildren(); /** - * Create the Interface used to access the real model. This method is called - * by the sashes window to get the interface. The method is called only once - * for a given object. + * Create the Interface used to access the real model. + * This method is called by the sashes window to get the interface. + * The method is called only once for a given object. * * @param child * A child returned by getChildren(). diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java index ce6f2fcda62..a17eab59db8 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java @@ -13,11 +13,13 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + /** * @author dumoulin */ public abstract class AbstractModel { + /** * Return the parent of the model. Can be null in the case of rootModel. * @@ -25,6 +27,7 @@ public abstract class AbstractModel { */ abstract public AbstractModel getParent(); + /** * @param parent * the parent to set diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java index c9cb164e529..0287d0c3458 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java @@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; + /** * @author dumoulin */ @@ -35,6 +36,7 @@ public abstract class AbstractPanelModel extends AbstractModel implements IAbstr this.parent = parent; } + /** * Return the parent of the model. Can be null in the case of rootModel. * @@ -44,6 +46,7 @@ public abstract class AbstractPanelModel extends AbstractModel implements IAbstr return parent; } + /** * @param parent * the parent to set @@ -52,6 +55,7 @@ public abstract class AbstractPanelModel extends AbstractModel implements IAbstr this.parent = parent; } + /** * Lookup the folder containing the specified tabItem. * @@ -60,4 +64,5 @@ public abstract class AbstractPanelModel extends AbstractModel implements IAbstr */ abstract protected TabFolderModel lookupTabFolder(IPageModel tabItem); + } 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 e36ae91c710..e7a3935e6c9 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 @@ -20,6 +20,7 @@ import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelM import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; + /** * Simple implementation of the {@link ISashPanelModel}. * @@ -35,6 +36,8 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode protected int sashDirection; + + /** * @param children * @param sashDirection @@ -47,6 +50,7 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode this.sashDirection = sashDirection; } + /** * Set the left child. * @@ -83,10 +87,12 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode 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. + * 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. */ public IAbstractPanelModel createChildSashModel(Object rawModel) { return (IAbstractPanelModel)rawModel; @@ -112,6 +118,7 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode */ public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { + if(getLeftChild() == oldChild) setLeftChild(newChild); else if(getRightChild() == oldChild) @@ -119,6 +126,7 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode } + /** * * {@inheritDoc} @@ -132,9 +140,10 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode 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. + * Delete the sashModel. + * The childToDelete is removed from the tree, bypass the sashnode : the other child parent is set to sashnode parent. * * @param tabFolder */ @@ -148,6 +157,8 @@ public class SashPanelModel extends AbstractPanelModel implements ISashPanelMode 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/contentprovider/simple/SimpleSashWindowsContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java index d87ee839e65..9f2163a28de 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java @@ -23,12 +23,12 @@ import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; import org.eclipse.swt.SWT; /** - * A simple implementation of providers allowing sashes and folders. The tabs - * can be added and removed. + * A simple implementation of providers allowing sashes and folders. + * The tabs can be added and removed. * * @author dumoulin * @@ -54,6 +54,7 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv rootModel = new RootModel(currentTabFolder); } + /** * Add a listener listening on content changed. This listener will be * notified each time the content change. @@ -126,8 +127,8 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv } /** - * Move a tab from folder to folder. The change event is sent only once - * after the complete operation is performed. {@inheritDoc} + * Move a tab from folder to folder. + * The change event is sent only once after the complete operation is performed. {@inheritDoc} */ public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { // This implementation use (TabFolderModel), so we can cast safely @@ -168,41 +169,29 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv } /** - * Create a new folder and insert it at the specified side. Move the - * specified tab into the created Folder. + * Create a new folder and insert it at the specified side. Move the specified tab into the created Folder. * - * The change event is sent only once after the complete operation is - * performed. {@inheritDoc} + * The change event is sent only once after the complete operation is performed. {@inheritDoc} * - * @param referenceFolder - * The folder used as reference to insert the newly created - * Folder. - * @param side - * The side to which the created folder is inserted. Can be - * SWT.TOP, DOWN, LEFT, RIGHT. + * @param referenceFolder The folder used as reference to insert the newly created Folder. + * @param side The side to which the created folder is inserted. Can be SWT.TOP, DOWN, LEFT, RIGHT. */ public void createFolder(ITabFolderModel sourceFolder, int tabIndex, ITabFolderModel referenceFolder, int side) { org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("createFolder()"); ITabFolderModel newFolder = doCreateFolder((TabFolderModel)sourceFolder, tabIndex, (TabFolderModel)referenceFolder, side); contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.CHANGED, this, sourceFolder)); - // return newFolder; + // return newFolder; } /** - * Create a new folder and insert it at the specified side of the reference - * folder. The change event is sent only once after the complete operation - * is performed. + * Create a new folder and insert it at the specified side of the reference folder. + * The change event is sent only once after the complete operation is performed. * - * This method is not part of the {@link SashWindowsContainer} API. It is - * here to help writing junit tests. + * This method is not part of the {@link SashWindowsContainer} API. It is here to help writing junit tests. * - * @param referenceFolder - * The folder used as reference to insert the newly created - * Folder. - * @param side - * The side to which the created folder is inserted. Can be - * SWT.TOP, DOWN, LEFT, RIGHT. + * @param referenceFolder The folder used as reference to insert the newly created Folder. + * @param side The side to which the created folder is inserted. Can be SWT.TOP, DOWN, LEFT, RIGHT. */ public ITabFolderModel createFolder(ITabFolderModel referenceFolder, int side) { org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("createFolder()"); @@ -213,8 +202,8 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv } /** - * Move a tab from folder to folder. The change event is sent only once - * after the complete operation is performed. + * Move a tab from folder to folder. + * The change event is sent only once after the complete operation is performed. * * @return The moved tab. */ @@ -226,9 +215,9 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv } /** - * Move a tab from folder to folder. The tab is added at the end of the - * target folder. The change event is sent only once after the complete - * operation is performed. {@inheritDoc} + * Move a tab from folder to folder. + * The tab is added at the end of the target folder. + * The change event is sent only once after the complete operation is performed. {@inheritDoc} */ private void doMoveTab(TabFolderModel srcFolderModel, int sourceIndex, TabFolderModel targetFolderModel) { @@ -290,8 +279,8 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv } /** - * Insert the folderToInsert on the specified side of the refFolder. Create - * and insert the requested SashModel. + * Insert the folderToInsert on the specified side of the refFolder. Create and insert the + * requested SashModel. * * @param folderToInsert * @param refFolder @@ -381,10 +370,9 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv * Lookup the folder containing the specified tabItem. * * @param tabItem - * Item for which a folder is looked for. If the item is null, - * return the first folder encountered. - * @return The folder containing the item, or the first encountered folder - * if item is null. + * Item for which a folder is looked for. If the item is null, return + * the first folder encountered. + * @return The folder containing the item, or the first encountered folder if item is null. */ private TabFolderModel lookupPageFolder(IPageModel tabItem) { return rootModel.lookupTabFolder(tabItem); @@ -424,8 +412,7 @@ public class SimpleSashWindowsContentProvider implements ISashWindowsContentProv * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) * * @param rawModel - * Object identifying the current folder. In this implementation, - * the object is the FolderModel. + * Object identifying the current folder. In this implementation, the object is the FolderModel. */ public void setCurrentFolder(Object rawModel) { if(!(rawModel instanceof TabFolderModel)) { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java index 67ce0bff0ed..79b89c0809b 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java @@ -55,12 +55,10 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode } /** - * This default implementation return directly the child which is already of - * the appropriate type. + * This default implementation return directly the child which is already of the appropriate type. */ public IPageModel createChildSashModel(Object child) { - // In this default implementation, the child is already of the - // appropriate type. + // In this default implementation, the child is already of the appropriate type. return (IPageModel)child; } @@ -109,8 +107,8 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode } /** - * Move a tab inside the folder. Moves the tab from the old position to the - * new position. + * Move a tab inside the folder. + * Moves the tab from the old position to the new position. * * @param oldIndex * the position of the tab before the move. @@ -132,6 +130,7 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode if(listSize == 0) return; + // Move IPageModel toMove = children.remove(oldIndex); children.add(newIndex, toMove); @@ -139,7 +138,8 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode } /** - * Add a new model. Do not fire change Event + * Add a new model. + * Do not fire change Event * * @param newModel */ @@ -148,7 +148,8 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode } /** - * Add a model at the specified position. Do not fire change Event + * Add a model at the specified position. + * Do not fire change Event * * @param index * @param newModel @@ -161,7 +162,8 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode } /** - * Remove the specified tab. Do not fire change Event + * Remove the specified tab. + * Do not fire change Event * * @param index * @return @@ -193,7 +195,8 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode } /** - * Remove the specified tab. Do not fire change Event + * Remove the specified tab. + * Do not fire change Event * * @param tabItem */ @@ -214,8 +217,8 @@ public class TabFolderModel extends AbstractPanelModel implements ITabFolderMode * Get a folder by one of its tab. * * @param tabItem - * Item for which a folder is looked for. If the item is null, - * return the first folder encountered. + * Item for which a folder is looked for. If the item is null, return + * the first folder encountered. * @return The folder if it contains the item, or if item is null. */ @Override diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java index 6ac26058385..3099e3853a3 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java @@ -25,8 +25,8 @@ import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; /** - * A simple implementation of providers allowing only one single folder - * containing tabs. The tabs can be added and removed. + * A simple implementation of providers allowing only one single folder containing tabs. + * The tabs can be added and removed. * * @author dumoulin */ @@ -154,8 +154,7 @@ public class SingleFolderContentProvider implements ISashWindowsContentProvider, } /** - * Remove the specified tab. As we have only one folder, this should be from - * the currentFolder {@inheritDoc} + * Remove the specified tab. As we have only one folder, this should be from the currentFolder {@inheritDoc} */ public void removePage(ITabFolderModel parentFolder, int tabIndex) { removePage(tabIndex); @@ -252,8 +251,8 @@ public class SingleFolderContentProvider implements ISashWindowsContentProvider, } /** - * Move a tab from folder to folder. As this implementation has only one - * folder, this can't happen. Do nothing. {@inheritDoc} + * Move a tab from folder to folder. + * As this implementation has only one folder, this can't happen. Do nothing. {@inheritDoc} */ public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { return; diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java index 482b7391783..cd1e4274d0b 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java @@ -53,12 +53,10 @@ public class SingleFolderModel implements ITabFolderModel { } /** - * This default implementation return directly the child which is already of - * the appropriate type. + * This default implementation return directly the child which is already of the appropriate type. */ public IPageModel createChildSashModel(Object child) { - // In this default implementation, the child is already of the - // appropriate type. + // In this default implementation, the child is already of the appropriate type. return (IPageModel)child; } @@ -107,8 +105,8 @@ public class SingleFolderModel implements ITabFolderModel { } /** - * Move a tab inside the folder. Moves the tab from the old position to the - * new position. + * Move a tab inside the folder. + * Moves the tab from the old position to the new position. * * @param oldIndex * the position of the tab before the move. @@ -131,6 +129,7 @@ public class SingleFolderModel implements ITabFolderModel { if(listSize == 0) return; + // Move IPageModel toMove = itemModels.remove(oldIndex); itemModels.add(newIndex, toMove); diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java index 3dd300d0143..5ea52fde209 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java @@ -19,6 +19,7 @@ import java.util.List; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; import org.eclipse.papyrus.infra.core.sasheditor.internal.IMultiEditorManager; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -30,8 +31,7 @@ import org.eclipse.ui.internal.util.Util; import org.eclipse.ui.part.EditorPart; /** - * Base editor that can be subclassed to provide a multi page editor with sash - * windows. + * Base editor that can be subclassed to provide a multi page editor with sash windows. * * @author dumoulin */ @@ -62,8 +62,7 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * Set the contentProvider if not set. If it is already set, this method do - * not change it. + * Set the contentProvider if not set. If it is already set, this method do not change it. * * @param contentProvider */ @@ -74,27 +73,23 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * Create the provider. Subclass must implements this method. It should - * return the provider used by the editor. + * Create the provider. + * Subclass must implements this method. It should return the provider used by the editor. * */ abstract protected ISashWindowsContentProvider createPageProvider(); /** - * Handles a property change notification from a nested editor. The default - * implementation simply forwards the change to listeners on this multi-page - * editor by calling firePropertyChange with the same property - * id. For example, if the dirty state of a nested editor changes (property - * id IEditorPart.PROP_DIRTY), this method handles it by firing - * a property change event for IEditorPart.PROP_DIRTY to - * property listeners on this multi-page editor. + * Handles a property change notification from a nested editor. The default implementation simply forwards the change to + * listeners on this multi-page editor by calling firePropertyChange with the same property id. For example, if + * the dirty state of a nested editor changes (property id IEditorPart.PROP_DIRTY), this method handles it + * by firing a property change event for IEditorPart.PROP_DIRTY to property listeners on this multi-page + * editor. *

* Subclasses may extend or reimplement this method. *

* - * @copiedfrom - * org.eclipse.ui.part.MultiPageEditorPart.handlePropertyChange(int - * ) + * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart.handlePropertyChange(int) * * @param propertyId * the id of the property that changed @@ -104,9 +99,9 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * The MultiPageEditorPart implementation of this IEditorPart method sets its site to the given site, its - * input to the given input, and the site's selection provider to a MultiPageSelectionProvider. Subclasses may extend this - * method. + * The MultiPageEditorPart implementation of this IEditorPart method sets its site to the given + * site, its input to the given input, and the site's selection provider to a MultiPageSelectionProvider. + * Subclasses may extend this method. * * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart * @param site @@ -137,9 +132,9 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * Method to activate the editor. Called immediately after - * createPartControl() is complete. To be implemented by subclasses. Default - * implementation do nothing. + * Method to activate the editor. + * Called immediately after createPartControl() is complete. + * To be implemented by subclasses. Default implementation do nothing. */ protected void activate() { @@ -147,8 +142,9 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * Method to deactivate the editor. Called when dispose() is called. To be - * implemented by subclasses. Default implementation do nothing. + * Method to deactivate the editor. + * Called when dispose() is called. + * To be implemented by subclasses. Default implementation do nothing. */ protected void deactivate() { @@ -178,9 +174,8 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * If there is an adapter registered against the subclass of - * MultiPageEditorPart return that. Otherwise, delegate to the internal - * editor. + * If there is an adapter registered against the subclass of MultiPageEditorPart return that. Otherwise, delegate to the + * internal editor. * * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart * @@ -221,8 +216,8 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * Get the {@link ISashWindowsContainer}. Note the the ISashWindowsContainer - * can also be acuired with getAdapter(ISashWindowsContainer.class). + * Get the {@link ISashWindowsContainer}. + * Note the the ISashWindowsContainer can also be acuired with getAdapter(ISashWindowsContainer.class). */ public ISashWindowsContainer getISashWindowsContainer() { return sashContainer; @@ -243,16 +238,15 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements * * {@inheritDoc} * - * TODO Move this method aways. This method is too tightly coupled to the - * Papyrus GMF UML IEditor. It doesn't work on other kind of IEditor. It - * introduce problems in IEditor of other kinds + * TODO Move this method aways. This method is too tightly coupled to the Papyrus GMF UML IEditor. + * It doesn't work on other kind of IEditor. It introduce problems in IEditor of other kinds * * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#isDirty() * @deprecated A SaveAndDirtyService is used instead. */ @Override public boolean isDirty() { - // return sashContainer.isDirty(); + // return sashContainer.isDirty(); EditorVisitor visitor = new EditorVisitor(); sashContainer.visit(visitor); @@ -269,14 +263,12 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements * Notify all the editors that the multi editor has been saved.
* Fires the PROP_DIRTY property change. * - * TODO Move this method aways. This method is too tightly coupled to the - * Papyrus GMF UML IEditor. It doesn't work on other kind of IEditor. It - * introduce problems in IEditor of other kinds - * + * TODO Move this method aways. This method is too tightly coupled to the Papyrus GMF UML IEditor. + * It doesn't work on other kind of IEditor. It introduce problems in IEditor of other kinds * @deprecated A SaveAndDirtyService is used instead. */ protected void markSaveLocation() { - // return sashContainer.isDirty(); + // return sashContainer.isDirty(); EditorVisitor visitor = new EditorVisitor(); sashContainer.visit(visitor); @@ -287,7 +279,8 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements } /** - * A visitor allowing to collect the available IEditor. TODO : Remove + * A visitor allowing to collect the available IEditor. + * TODO : Remove * * @author dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java index f7a49058ead..99aa58efc74 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java @@ -3,11 +3,12 @@ */ package org.eclipse.papyrus.infra.core.sasheditor.editor; + /** - * Allows to access to properties of a Sash ComponentPage. This interface allows - * to read the data. User should not attent to modifiy or write the data in - * anyway. This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and in the - * SashContainer Visitor. + * Allows to access to properties of a Sash ComponentPage. + * This interface allows to read the data. User should not attent to modifiy or write the data in anyway. + * This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and + * in the SashContainer Visitor. * * @author cedric dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java index 5254420bdc9..e374e922d5e 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java @@ -5,11 +5,12 @@ package org.eclipse.papyrus.infra.core.sasheditor.editor; import org.eclipse.ui.IEditorPart; + /** - * Allows to access to properties of a Sash IEditor Page. This interface allows - * to read the data. User should not attent to modifiy or write the data in - * anyway. This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and in the - * SashContainer Visitor. + * Allows to access to properties of a Sash IEditor Page. + * This interface allows to read the data. User should not attent to modifiy or write the data in anyway. + * This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and + * in the SashContainer Visitor. * * @author cedric dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java index d6bbcabdbe8..d7098283915 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java @@ -18,8 +18,8 @@ import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IWorkbenchPartSite; /** - * Marker to mark a EditorPart as a MultiPartEditor. Provides methods needed by - * classes like MultiPageActionBarContributor and MultiPageSelectionProvider. + * Marker to mark a EditorPart as a MultiPartEditor. Provides methods needed by classes + * like MultiPageActionBarContributor and MultiPageSelectionProvider. */ public interface IMultiPageEditorPart { @@ -38,8 +38,8 @@ public interface IMultiPageEditorPart { public IWorkbenchPartSite getSite(); /** - * Get the IEditorSite associated to this MultiPageEditorPart. This return - * the same object as getSite(). + * Get the IEditorSite associated to this MultiPageEditorPart. + * This return the same object as getSite(). * * @return */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java index d2a683905fe..470ce40107e 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java @@ -6,10 +6,11 @@ package org.eclipse.papyrus.infra.core.sasheditor.editor; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Control; + /** - * Allows to access to properties of a Sash Page. This interface allows to read - * the data. User should not attent to modifiy or write the data in anyway. This - * interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event. + * Allows to access to properties of a Sash Page. + * This interface allows to read the data. User should not attent to modifiy or write the data in anyway. + * This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event. * * @author cedric dumoulin * @@ -31,8 +32,8 @@ public interface IPage { public Image getPageIcon(); /** - * Get the raw model corresponding to this node. This is the object provided - * to {@link ITabFolderModel.getChildren()} + * Get the raw model corresponding to this node. + * This is the object provided to {@link ITabFolderModel.getChildren()} * * @return */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java index 0037bc7be0b..fe072cb81b8 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java @@ -3,6 +3,8 @@ */ package org.eclipse.papyrus.infra.core.sasheditor.editor; + + /** * @author cedric dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java index e2e41c10eeb..ce4f7257207 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java @@ -3,6 +3,9 @@ */ package org.eclipse.papyrus.infra.core.sasheditor.editor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; + + /** * A Visitor used to visit all the {@link IPage} of a {@link SashWindowsContainer}. * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java index 8f75f476643..27857bfeb91 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java @@ -4,6 +4,7 @@ import java.util.List; import org.eclipse.jface.action.MenuManager; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashContainerEventsListener; import org.eclipse.ui.IEditorPart; public interface ISashWindowsContainer { @@ -16,29 +17,30 @@ public interface ISashWindowsContainer { public abstract IEditorPart getActiveEditor(); /** - * Get the currently active SashWindows Page. This is s + * Get the currently active SashWindows Page. + * This is s * * @return An {@link IPage} allowing to access current page data. */ public abstract IPage getActiveSashWindowsPage(); /** - * Get the list of visible IPages. The visible IPages are the one that have - * there diagram area visible. + * Get the list of visible IPages. The visible IPages are the one that have there diagram area + * visible. * * @return */ public List getVisiblePages(); /** - * Get the list of visible IEditorPart obtain from the pages of type - * IEditorPage. The visible IPages are the one that have there diagram area + * Get the list of visible IEditorPart obtain from the pages of type IEditorPage. + * The visible IPages are the one that have there diagram area * visible. * * @return */ public List getVisibleIEditorParts(); - + /** * The AbstractMultiPageSashEditor implementation of this IWorkbenchPart method sets focus on the active nested * editor, if there is one. @@ -49,7 +51,8 @@ public interface ISashWindowsContainer { public abstract void setFocus(); /** - * Refresh the SashWindows. Synchronize the internal structure with the {@link ISashWindowsContentProvider}. + * Refresh the SashWindows. + * Synchronize the internal structure with the {@link ISashWindowsContentProvider}. */ public abstract void refreshTabs(); @@ -68,8 +71,8 @@ public interface ISashWindowsContainer { public abstract void removePageChangedListener(IPageChangedListener pageChangedListener); /** - * Add a listener on Page LifeCycle events. This implementation delegates to - * the internal PageTracker. + * Add a listener on Page LifeCycle events. + * This implementation delegates to the internal PageTracker. * * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) * @param listener @@ -85,14 +88,9 @@ public interface ISashWindowsContainer { * */ public void removeLifeCycleListener(SashContainerEventsListener listener); - /** - * Set a {@link MenuManager} used to manage a contextual menu that is shown - * on the tabs area of the folders. - * - * @param menuManager - * The {@link MenuManager} used to create the menu on the tab - * area. + * Set a {@link MenuManager} used to manage a contextual menu that is shown on the tabs area of the folders. + * @param menuManager The {@link MenuManager} used to create the menu on the tab area. */ - public abstract void setFolderTabMenuManager(MenuManager menuManager); + public abstract void setFolderTabMenuManager( MenuManager menuManager ); } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java index 4b9e0f5c99d..a387aa8217b 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java @@ -3,6 +3,8 @@ */ package org.eclipse.papyrus.infra.core.sasheditor.editor; + + /** * @author dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java index 5e480d5f43e..7286dab9ffd 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java @@ -5,60 +5,64 @@ package org.eclipse.papyrus.infra.core.sasheditor.editor; import java.util.logging.Logger; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashContainerEventsListener; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IPropertyListener; import org.eclipse.ui.IWorkbenchPart; + /** - * This class take care to refresh a Sash Tab (name and icon) when its model - * change. The class listen to IEditor property change, and refresh the - * corresponding tab accordingly. The class also listen on {@link SashWindowsContainer} page's life cycle in order to attach/remove the - * listener on pages. + * This class take care to refresh a Sash Tab (name and icon) when its model change. + * The class listen to IEditor property change, and refresh the corresponding tab + * accordingly. + * The class also listen on {@link SashWindowsContainer} page's life cycle in order to + * attach/remove the listener on pages. * - * The class can be extended. + * The class can be extended. * * @author cedric dumoulin - * + * */ public class SashTabDecorationSynchronizer { /** * Logger for debug purpose. */ - Logger log = Logger.getLogger(this.getClass().getName()); - + Logger log = Logger.getLogger(this.getClass().getName() ); + /** * The container to synchronize. */ private SashWindowsContainer container; - + /** * Listener on Container'pages life cycle. */ SashContainerEventsListener pageLifeCycleListener = new SashContainerEventsListener() { - + public void pageChanged(IPage newPage) { } - + public void pageOpened(IPage page) { attachPage(page); - + } - + public void pageDeactivated(IPage page) { } - + public void pageClosed(IPage page) { detachPage(page); - + } - + public void pageActivated(IPage page) { } - + public void pageAboutToBeOpened(IPage page) { } - + public void pageAboutToBeClosed(IPage page) { } }; @@ -67,29 +71,28 @@ public class SashTabDecorationSynchronizer { * Listener on changes of an {@link IEditorPart} */ private IPropertyListener editorPartPropertyListener = new IPropertyListener() { - + public void propertyChanged(Object source, int propId) { - if(propId == IWorkbenchPart.PROP_TITLE && source instanceof IEditorPart) { + if(propId == IWorkbenchPart.PROP_TITLE && source instanceof IEditorPart ) + { refreshContainerTabForPage((IEditorPart)source); } - + } }; /** * * Constructor. - * - * @param container - * The container to synchronize. + * @param container The container to synchronize. * */ - public SashTabDecorationSynchronizer(SashWindowsContainer container) { + public SashTabDecorationSynchronizer( SashWindowsContainer container) { this.container = container; attachContainerPages(); attachListeners(); } - + /** * Detach any listeners. */ @@ -97,42 +100,42 @@ public class SashTabDecorationSynchronizer { detachListeners(); detachContainerPages(); } - + /** * Attach listeners requested by the class. */ protected void attachListeners() { container.addLifeCycleListener(pageLifeCycleListener); } - + /** * Detach listeners requested by the class. */ protected void detachListeners() { container.removeLifeCycleListener(pageLifeCycleListener); } - + /** * Start listening on change for the specified page. - * * @param page */ protected void attachPage(IPage page) { - if(page instanceof IEditorPage) { + if( page instanceof IEditorPage ) + { log.fine("attachPage( " + page + " )"); IEditorPage editorPage = (IEditorPage)page; editorPage.getIEditorPart().addPropertyListener(editorPartPropertyListener); } - + } /** * Stop listening onchange for the specified page. - * * @param page */ protected void detachPage(IPage page) { - if(page instanceof IEditorPage) { + if( page instanceof IEditorPage ) + { log.fine("attachPage( " + page + " )"); IEditorPage editorPage = (IEditorPage)page; editorPage.getIEditorPart().removePropertyListener(editorPartPropertyListener); @@ -143,25 +146,24 @@ public class SashTabDecorationSynchronizer { // lookup page IPage page = container.lookupIPageByIEditorPart(source); refreshContainerTabForPage(page); - + } /** * Refresh the tab for the specified page - * * @param page */ - protected void refreshContainerTabForPage(IPage page) { + protected void refreshContainerTabForPage( IPage page ) { container.refreshPageTab(page); } - + /** * Iterate on pages owned by the container, and call detachPage for each. */ private void detachContainerPages() { // Visit all pages of the container. container.visit(new DetachVisitor()); - + } /** @@ -170,42 +172,40 @@ public class SashTabDecorationSynchronizer { private void attachContainerPages() { // Visit all pages of the container. container.visit(new AttachVisitor()); - + } /** * Visitor to visit all pages of the container and attach the page. - * * @author dumoulin - * + * */ - private class AttachVisitor implements IPageVisitor { - - public void accept(IComponentPage page) { - } - - public void accept(IEditorPage page) { - attachPage(page); - - } + private class AttachVisitor implements IPageVisitor { + public void accept(IComponentPage page) { } + public void accept(IEditorPage page) { + attachPage(page); + + } + + } + /** * Visitor to visit all pages of the container and attach the page. - * * @author dumoulin - * + * */ - private class DetachVisitor implements IPageVisitor { + private class DetachVisitor implements IPageVisitor { - public void accept(IComponentPage page) { - } - - public void accept(IEditorPage page) { - detachPage(page); - - } + public void accept(IComponentPage page) { + } + public void accept(IEditorPage page) { + detachPage(page); + } + + } } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java index 537a2c5656e..d43ecb505ad 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java @@ -6,6 +6,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.editor; import java.util.ArrayList; import java.util.List; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IWorkbenchPage; @@ -18,12 +19,10 @@ import org.eclipse.ui.IWorkbenchPart; *
  • - containerChanged - the active editor has changed, and so the currently active container.
  • * * - * This class require the current Eclipse page in order to listen on active - * editor changed. This class connect itself to the Workbench editor changed - * event. Then, it ask the current editor for a ISashWindowsContainer (using - * getAdaptor() ). If the editor return a ISashWindowsContainer, this class - * listen to the pageChanged events. This class takes care to connect itself to - * the new ISashWindowsContainer when the editor changes. + * This class require the current Eclipse page in order to listen on active editor changed. + * This class connect itself to the Workbench editor changed event. Then, it ask the current editor for a ISashWindowsContainer (using getAdaptor() ). + * If the editor return a ISashWindowsContainer, + * this class listen to the pageChanged events. This class takes care to connect itself to the new ISashWindowsContainer when the editor changes. * * @TODO rename as SashWindowsEventsNotifier * @author cedric dumoulin @@ -32,14 +31,12 @@ import org.eclipse.ui.IWorkbenchPart; public class SashWindowsEventsProvider { /** - * List of listeners that will be notified when the current Sash Page has - * changed. + * List of listeners that will be notified when the current Sash Page has changed. */ private PageChangedListeners pageEventsManager = new PageChangedListeners(); /** - * List of listeners that will be notified when the SashWindowsContainer has - * changed. + * List of listeners that will be notified when the SashWindowsContainer has changed. */ private SashWindowsContainerChangedListeners containerEventsManager = new SashWindowsContainerChangedListeners(); @@ -61,28 +58,28 @@ public class SashWindowsEventsProvider { /** Currently active page, or null if no container is active */ private IPage activePage = null; + private IPartListener workbenchPartListener = new IPartListener() { public void partOpened(IWorkbenchPart part) { - // System.out.println("partOpened("+ part +")"); + // System.out.println("partOpened("+ part +")"); } public void partDeactivated(IWorkbenchPart part) { - // System.out.println("partDeactivated("+ part +")"); + // System.out.println("partDeactivated("+ part +")"); } public void partClosed(IWorkbenchPart part) { - // System.out.println("("+ part +")"); + // System.out.println("("+ part +")"); } public void partBroughtToTop(IWorkbenchPart part) { - // System.out.println("partClosed("+ part +")"); + // System.out.println("partClosed("+ part +")"); } public void partActivated(IWorkbenchPart part) { - // System.out.println("partActivated(" + part + ") - activeEditor: " - // + workbenchPage.getActiveEditor()); + // System.out.println("partActivated(" + part + ") - activeEditor: " + workbenchPage.getActiveEditor()); checkActiveEditorChange(); } }; @@ -99,8 +96,8 @@ public class SashWindowsEventsProvider { /** * - * Constructor. Page can be acquired with : - * IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + * Constructor. + * Page can be acquired with : IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); */ public SashWindowsEventsProvider(IWorkbenchPage page) { @@ -129,19 +126,18 @@ public class SashWindowsEventsProvider { newContainer = (ISashWindowsContainer)editorPart.getAdapter(ISashWindowsContainer.class); } - // // Set SashContainer and ActivePage - // currentContainer = newContainer; - // if( currentContainer != null) - // { - // activePage = newContainer.getActiveSashWindowsPage(); - // System.err.println("activePage=" + activePage.getPageTitle() - // + ", tab index=" + currentContainer.); - // } + // // Set SashContainer and ActivePage + // currentContainer = newContainer; + // if( currentContainer != null) + // { + // activePage = newContainer.getActiveSashWindowsPage(); + // System.err.println("activePage=" + activePage.getPageTitle() + // + ", tab index=" + currentContainer.); + // } } /** - * Return the currently active ISashWindowsContainer or null if none is - * actif. + * Return the currently active ISashWindowsContainer or null if none is actif. * * @return */ @@ -150,8 +146,8 @@ public class SashWindowsEventsProvider { } /** - * Return the currently active {@link IEditorPart} owning the currently - * active ISashWindowsContaineror. Return null if no container is actif. + * Return the currently active {@link IEditorPart} owning the currently active ISashWindowsContaineror. + * Return null if no container is actif. * * @return */ @@ -162,8 +158,8 @@ public class SashWindowsEventsProvider { } /** - * Return the currently active page associated to the currently active - * Container. Return null if no container is actif. + * Return the currently active page associated to the currently active Container. + * Return null if no container is actif. * * @return */ @@ -192,9 +188,9 @@ public class SashWindowsEventsProvider { } /** - * Register a listener listeneing on editor change. Page can be acuired with - * : IWorkbenchPage page = - * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + * Register a listener listeneing on editor change. + * Page can be acuired with : + * IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); */ private void registerEditorChangedListener() { @@ -202,9 +198,9 @@ public class SashWindowsEventsProvider { } /** - * This method is called when the active editor has change. The method - * checks the new editor and send appropriate events. The editor can be - * null. + * This method is called when the active editor has change. + * The method checks the new editor and send appropriate events. + * The editor can be null. * * @param newEditor * The new editor of null if none is set. @@ -224,9 +220,8 @@ public class SashWindowsEventsProvider { } /** - * This method is called when the active container has changed. The - * pageChangedListener is removed from the oldContainer, and attached to the - * newContainer. + * This method is called when the active container has changed. + * The pageChangedListener is removed from the oldContainer, and attached to the newContainer. * * @param newContainer */ @@ -251,8 +246,8 @@ public class SashWindowsEventsProvider { } /** - * Send an event indicating a containerChanged. Propagate the event to all - * the listeners. + * Send an event indicating a containerChanged. + * Propagate the event to all the listeners. * * @param activeEditor */ @@ -262,8 +257,8 @@ public class SashWindowsEventsProvider { } /** - * Send an event indicating a pageChanged. Propagate the event to all the - * listeners. + * Send an event indicating a pageChanged. + * Propagate the event to all the listeners. * * @param activeEditor */ @@ -405,8 +400,7 @@ public class SashWindowsEventsProvider { } /** - * A list of {@link ISashWindowsContainerChangedListener} listening on - * container changed event. + * A list of {@link ISashWindowsContainerChangedListener} listening on container changed event. * * @author dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java index a5c7626003e..a213d0e8b05 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java @@ -9,34 +9,34 @@ import org.eclipse.ui.IEditorActionBarContributor; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.part.EditorActionBarContributor; + /** * * An ActionBarContributor composed of ActionBarContributor from multi editor. - * This ActionBarContributor switch to the contributor dedicated to the active - * editor in a MultiPageEditor environement. + * This ActionBarContributor switch to the contributor dedicated to the active editor in + * a MultiPageEditor environement. * * @author dumoulin * */ public class ComposedActionBarContributor extends MultiPageEditorActionBarContributor { - // /** - // * List of contributors. - // */ - // protected ContributorMap, - // EditorActionBarContributor> contributors = new ContributorMap, EditorActionBarContributor>(); - // - // - // /** - // * Contributor used as default. - // */ - // protected EditorActionBarContributor defaultContributor; - // - // /** - // * The currently active contributor. - // */ - // protected EditorActionBarContributor activeContributor; + // /** + // * List of contributors. + // */ + // protected ContributorMap, EditorActionBarContributor> contributors = new ContributorMap, EditorActionBarContributor>(); + // + // + // /** + // * Contributor used as default. + // */ + // protected EditorActionBarContributor defaultContributor; + // + // /** + // * The currently active contributor. + // */ + // protected EditorActionBarContributor activeContributor; + /** The currently active nested editor */ protected IEditorPart activeNestedEditor; @@ -56,9 +56,8 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri *

    * * @param activeEditor - * the new active editor, or null if there is no - * active page, or if the active page does not have a - * corresponding editor + * the new active editor, or null if there is no active page, or if the + * active page does not have a corresponding editor */ @Override public void setActivePage(IEditorPart activeEditor) { @@ -77,9 +76,9 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri activeNestedEditor = activeEditor; - // System.out.println(this.getClass().getSimpleName() - // + ".setActivePage(" + activeEditor - // + ") :" + getActiveContributor()); +// System.out.println(this.getClass().getSimpleName() +// + ".setActivePage(" + activeEditor +// + ") :" + getActiveContributor()); // Propagate call if possible // Call setActiveEditor() on nested contributor. @@ -87,9 +86,8 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri if(contributor != this && contributor instanceof EditorActionBarContributor) ((EditorActionBarContributor)contributor).setActiveEditor(activeEditor); - // if(contributor != this && contributor instanceof - // IMultiPageEditorActionBarContributor) - // ((IMultiPageEditorActionBarContributor)contributor).setActivePage(activeEditor); + // if(contributor != this && contributor instanceof IMultiPageEditorActionBarContributor) + // ((IMultiPageEditorActionBarContributor)contributor).setActivePage(activeEditor); } @@ -111,11 +109,10 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri // Switch the editor and activeContributor. super.setActiveEditor(part); // Now, propagate to the new activeContributor - // IEditorActionBarContributor activeContributor = - // getActiveContributor(); + // IEditorActionBarContributor activeContributor = getActiveContributor(); // - // if(activeContributor!=this) - // activeContributor.setActiveEditor(part); + // if(activeContributor!=this) + // activeContributor.setActiveEditor(part); } /** @@ -129,12 +126,13 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri if(activeNestedEditor == null) return this; - // + // return activeNestedEditor.getEditorSite().getActionBarContributor(); } + // ************************************************ // - // Propagate method calls // + // Propagate method calls // // ************************************************ // /** @@ -142,14 +140,13 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri * * @return the action bars */ - // public IActionBars getActionBars() { - // IEditorActionBarContributor activeContributor = getActiveContributor(); - // if( activeContributor!=this && activeContributor instanceof - // EditorActionBarContributor) - // return - // ((EditorActionBarContributor)getActiveContributor()).getActionBars(); - // else - // return super.getActionBars(); - // } + // public IActionBars getActionBars() { + // IEditorActionBarContributor activeContributor = getActiveContributor(); + // if( activeContributor!=this && activeContributor instanceof EditorActionBarContributor) + // return ((EditorActionBarContributor)getActiveContributor()).getActionBars(); + // else + // return super.getActionBars(); + // } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java index 51d294c99a0..6c366a387e4 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java @@ -17,10 +17,9 @@ import org.eclipse.ui.IEditorPart; /** * Interface implemented by ActionBarContributor dedicated to MultiEditor. - * ActionBarContributor that want to be advised of a page change should - * implement this interface. Another way should be to use a Observer/Observee - * mechanism, allowing to remove the dependancy from the editor to the - * ActionBarContributor ? + * ActionBarContributor that want to be advised of a page change should implement this interface. + * Another way should be to use a Observer/Observee mechanism, allowing to remove the dependancy + * from the editor to the ActionBarContributor ? * * @author dumoulin * @@ -28,8 +27,7 @@ import org.eclipse.ui.IEditorPart; public interface IMultiPageEditorActionBarContributor { /** - * Sets the active page of the the multi-page editor to be the given editor. - * Redirect actions to the given editor if actions are not already being + * Sets the active page of the the multi-page editor to be the given editor. Redirect actions to the given editor if actions are not already being * sent to it. *

    * This method is called whenever the page changes. Subclasses must implement this method to redirect actions to the given editor (if not already @@ -37,9 +35,7 @@ public interface IMultiPageEditorActionBarContributor { *

    * * @param activeEditor - * the new active editor, or null if there is no - * active page, or if the active page does not have a - * corresponding editor + * the new active editor, or null if there is no active page, or if the active page does not have a corresponding editor */ public abstract void setActivePage(IEditorPart activeEditor); diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java index ef6e754d645..3264225df18 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java @@ -17,8 +17,7 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.part.EditorActionBarContributor; /** - * Abstract base class for managing the installation/deinstallation of global - * actions for multi-page editors. + * Abstract base class for managing the installation/deinstallation of global actions for multi-page editors. *

    * Subclasses must implement setActivePage, and may reimplement any of the following methods: *

      @@ -42,9 +41,10 @@ public abstract class MultiPageEditorActionBarContributor extends EditorActionBa } /** - * Method declared on EditorActionBarContributor. Registers the contributor - * with the multi-page editor for future editor action redirection when the - * active page is changed, and sets the active page. + * Method declared on EditorActionBarContributor. + * Registers the contributor with the multi-page + * editor for future editor action redirection when the active page is changed, and sets + * the active page. */ public void setActiveEditor(IEditorPart part) { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java index 4d044f510ae..40693b11c07 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java @@ -20,9 +20,10 @@ import org.eclipse.gef.ui.actions.ActionRegistry; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; + /** - * Provide methods and services needed for Gef Editors. This class is intended - * to be used as a delegate inside classes providing MultiDiagramEditor. + * Provide methods and services needed for Gef Editors. + * This class is intended to be used as a delegate inside classes providing MultiDiagramEditor. * * @author dumoulin * @@ -33,11 +34,12 @@ public class MultiDiagramEditorGefDelegate { protected ActionRegistry actionRegistry; /** Synchronizer object */ - // private MultiPageSelectionSynchronizer synchronizer; + // private MultiPageSelectionSynchronizer synchronizer; /** List of listeners on SelectionChanged event */ private List selectionListeners = new ArrayList(1); + /** * This method should be called by the containing class. */ @@ -48,9 +50,9 @@ public class MultiDiagramEditorGefDelegate { } } + /** - * Adds a listener for selection changes in this selection provider. Has no - * effect if an identical listener is already registered. + * Adds a listener for selection changes in this selection provider. Has no effect if an identical listener is already registered. * * @param listener * a selection changed listener @@ -70,24 +72,22 @@ public class MultiDiagramEditorGefDelegate { return actionRegistry; } - // /** - // * Returns the selection synchronizer object. The synchronizer can be used - // to sync the selection of 2 or more EditPartViewers. - // * - // * @return the syncrhonizer - // */ - // public MultiPageSelectionSynchronizer getSelectionSynchronizer() { - // if (synchronizer == null) { - // synchronizer = new MultiPageSelectionSynchronizer(); - // // Hook this editor. - // // synchronizer.addViewer(this); - // } - // return synchronizer; - // } + // /** + // * Returns the selection synchronizer object. The synchronizer can be used to sync the selection of 2 or more EditPartViewers. + // * + // * @return the syncrhonizer + // */ + // public MultiPageSelectionSynchronizer getSelectionSynchronizer() { + // if (synchronizer == null) { + // synchronizer = new MultiPageSelectionSynchronizer(); + // // Hook this editor. + //// synchronizer.addViewer(this); + // } + // return synchronizer; + // } /** - * Removes the given selection change listener from this selection provider. - * Has no affect if an identical listener is not registered. + * Removes the given selection change listener from this selection provider. Has no affect if an identical listener is not registered. * * @param listener * the selection changed listener to be removed diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java index 1e9ef702e0c..66f9a79f09a 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java @@ -18,8 +18,10 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.internal.dnd.IDropTarget; + /** - * Common ancestor of Panel Parts. Panels are sashes and folders. + * Common ancestor of Panel Parts. + * Panels are sashes and folders. * * @author cedric dumoulin */ @@ -41,7 +43,8 @@ public abstract class AbstractPanelPart extends AbstractPart { } /** - * Create the SWT controls. This method is called by the SWT parent. + * Create the SWT controls. + * This method is called by the SWT parent. * * @param container */ @@ -68,8 +71,8 @@ public abstract class AbstractPanelPart extends AbstractPart { abstract public void synchronize2(PartLists existingParts); /** - * Return true is the part is for the specified raw model. Return false - * otherwise. + * Return true is the part is for the specified raw model. + * Return false otherwise. * * @param rawModel * @return @@ -77,10 +80,9 @@ public abstract class AbstractPanelPart extends AbstractPart { abstract public boolean isPartFor(Object rawModel); /** - * Orphan this node. The parent is set to null, but control is left - * unchanged. The node can be reattached with reparent(). Change garbage - * state to {@link GarbageState.ORPHANED}. This method as no effect if the - * Tile has already been reparented. + * Orphan this node. The parent is set to null, but control is left unchanged. + * The node can be reattached with reparent(). Change garbage state to {@link GarbageState.ORPHANED}. + * This method as no effect if the Tile has already been reparented. */ public void orphan() { // orphan only if we are in UNCHANGED state @@ -90,8 +92,10 @@ public abstract class AbstractPanelPart extends AbstractPart { } } + /** - * Mark this Page as UNCHANGED. The PAge should be in the COLLECTED state. + * Mark this Page as UNCHANGED. + * The PAge should be in the COLLECTED state. * * @see * @return the parent @@ -117,8 +121,7 @@ public abstract class AbstractPanelPart extends AbstractPart { abstract public void reparent(IPanelParent newParent, Composite swtParent); /** - * Collect all the parts. The method is called recursively in the tree of - * parts. + * Collect all the parts. The method is called recursively in the tree of parts. * * @param parts * The list into which parts are added. @@ -144,8 +147,7 @@ public abstract class AbstractPanelPart extends AbstractPart { abstract public AbstractPart findPart(Object control); /** - * Locates the part that intersects the given point and that have the - * expected type + * Locates the part that intersects the given point and that have the expected type * * @param toFind * Position in Display coordinate. @@ -163,8 +165,10 @@ public abstract class AbstractPanelPart extends AbstractPart { abstract public Composite getControl(); /** - * Get the drop target. Used by the drag tab mechanism. + * Get the drop target. + * Used by the drag tab mechanism. */ abstract public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position); + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java index a7d8ba2f5bf..472d4f16d33 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java @@ -14,11 +14,11 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; + /** - * Base class of the Part hierarchy. This class provides common methods for - * sashwindows Parts. + * Base class of the Part hierarchy. + * This class provides common methods for sashwindows Parts. * * * @author dumoulin @@ -40,6 +40,7 @@ public abstract class AbstractPart { UNVISITED, ORPHANED, REPARENTED, CREATED, UNCHANGED } + /** * The main container. */ @@ -48,6 +49,7 @@ public abstract class AbstractPart { /** Garbage state used during refresh */ protected GarbageState garbageState = GarbageState.CREATED; + /** * @param sashWindowsContainer */ @@ -55,6 +57,7 @@ public abstract class AbstractPart { this.sashWindowsContainer = sashWindowsContainer; } + /** * Get the {@link SashWindowsContainer}. * @@ -64,6 +67,7 @@ public abstract class AbstractPart { return sashWindowsContainer; } + /** * Get the content provider of the sashwindows. * @@ -98,4 +102,5 @@ public abstract class AbstractPart { return garbageState; } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java index 1c994ac127b..b29df4c97c1 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java @@ -18,7 +18,6 @@ import java.util.logging.Logger; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; import org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor.IMultiPageEditorActionBarContributor; import org.eclipse.papyrus.infra.core.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener; import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider; @@ -33,12 +32,14 @@ import org.eclipse.ui.internal.services.INestable; import org.eclipse.ui.part.MultiPageEditorActionBarContributor; import org.eclipse.ui.services.IServiceLocator; + /** - * This class is used to switch the services of a nested editor when the active - * nested editor change. This class is a {@link IActiveEditorChangedListener} registered to the {@link ActivePageTracker} by the - * {@link SashWindowsContainer}. + * This class is used to switch the services of a nested editor when the active nested editor change. + * This class is a {@link IActiveEditorChangedListener} registered to the {@link ActivePageTracker} + * by the {@link SashWindowsContainer}. * - * When a new Editor is set active, by calling {@link #setActiveEditor(PagePart)}, following actions are performed: + * When a new Editor is set active, by calling {@link #setActiveEditor(PagePart)}, following actions are + * performed: *
        *
      • deactivate services: nested site and keybinding
      • *
      • An event is sent to the ActionBarContributor if it accept it (by implementing {@link IMultiPageEditorActionBarContributor})
      • @@ -64,8 +65,8 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene private IEditorSite outerEditorSite; /** - * The active service locator. This value may be null if there - * is no selected page, or if the selected page is a control with no site. + * The active service locator. This value may be null if there is no selected page, or if the selected page is a control with no + * site. */ private INestable activeServiceLocator; @@ -80,9 +81,9 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene } /** - * Get the currently active IEditorPart, if any. Return null if there is no - * active IeditorPart. Method check if the active leaf encapsulate an - * IEditorPart. Return it if true. + * Get the currently active IEditorPart, if any. + * Return null if there is no active IeditorPart. + * Method check if the active leaf encapsulate an IEditorPart. Return it if true. * * @return The currentlyactive IEditorPart or null. */ @@ -91,9 +92,9 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene } /** - * Get IEditorPart of the specified PagePart, if any. Return null if there - * is no IeditorPart. Method check if the leaf encapsulate an IEditorPart. - * Return it if true. + * Get IEditorPart of the specified PagePart, if any. + * Return null if there is no IeditorPart. + * Method check if the leaf encapsulate an IEditorPart. Return it if true. * * @return The IEditorPart or null. */ @@ -109,7 +110,8 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene } /** - * Called when the active editor is changed. Perform requested operations. + * Called when the active editor is changed. + * Perform requested operations. * * @param oldEditor * @param newEditor @@ -119,9 +121,7 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene return; } - // System.out.println(getClass().getSimpleName() + - // ".activeEditorChange('" + (newEditor != null ? - // newEditor.getPageTitle() : "null") + "')"); + // System.out.println(getClass().getSimpleName() + ".activeEditorChange('" + (newEditor != null ? newEditor.getPageTitle() : "null") + "')"); activeEditor = newEditor; @@ -137,15 +137,15 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene propagateSelectionChanged(); activateServices(); - // + // if(newEditor != null) newEditor.setFocus(); } /** * Change the current selection of the outermost editor (the main editor). - * Send a {@link SelectionChangedEvent} event to the outerProvider. The - * event contains the current selection of the new activeEditor. + * Send a {@link SelectionChangedEvent} event to the outerProvider. The event contains the current selection + * of the new activeEditor. * * @param editor * The new activeEditor. @@ -156,8 +156,7 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene IEditorPart editorPart = getActiveIEditorPart(); // Propagate the selection change event. - // Get the selection of the new activeEditor and send an - // SelectionChangedEvent to the outerProvider (provider of the main + // Get the selection of the new activeEditor and send an SelectionChangedEvent to the outerProvider (provider of the main // editor) with the selection. if(editorPart != null) { ISelectionProvider selectionProvider = editorPart.getSite().getSelectionProvider(); @@ -171,8 +170,9 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene provider.firePostSelectionChanged(event); } else { if(log.isLoggable(Level.WARNING)) { - log.warning(this.getClass().getSimpleName() + " did not propogate selection for " //$NON-NLS-1$ - + editorPart.getTitle()); + log.warning(this.getClass().getSimpleName() + + " did not propogate selection for " //$NON-NLS-1$ + + editorPart.getTitle()); } } } @@ -180,8 +180,8 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene } /** - * Activates services of the active editor: site, keybinding deactivate old - * active site. + * Activates services of the active editor: site, keybinding + * deactivate old active site. */ @SuppressWarnings({ "restriction", "deprecation" }) private void activateServices() { @@ -191,9 +191,11 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene activeServiceLocator = null; } + // Get the service final IKeyBindingService service = getOuterEditorSite().getKeyBindingService(); + final IEditorPart editor = getActiveIEditorPart(); if(editor != null) { @@ -216,9 +218,9 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene } /** - * Deactivate services: old nested site if any and keybinding service if - * there is no active editor. Deactivate the key binding service. Deactivate - * it only if there is no editor selected. + * Deactivate services: old nested site if any and keybinding service if there is no active editor. + * Deactivate the key binding service. + * Deactivate it only if there is no editor selected. */ @SuppressWarnings({ "restriction", "deprecation" }) private void deactivateServices(boolean immediate) { @@ -242,8 +244,7 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene } /** - * Send message to the ActionBarContributor, like this it can switch the - * active editor. + * Send message to the ActionBarContributor, like this it can switch the active editor. */ private void fireChangeEventToActionBarContributor() { IEditorActionBarContributor contributor = getOuterEditorSite().getActionBarContributor(); @@ -267,4 +268,5 @@ public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListene return outerEditorSite; } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java index 78c6304a481..59f74099ae5 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java @@ -18,12 +18,11 @@ import java.util.List; import java.util.logging.Logger; import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener; -import org.eclipse.papyrus.infra.core.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener; + /** - * Instance of this class track the active Page. When the active Page change, - * the tracker receive an event on {@link #setActiveEditor(PagePart)}, and - * perform following tasks: + * Instance of this class track the active Page. + * When the active Page change, the tracker receive an event on {@link #setActiveEditor(PagePart)}, and perform following tasks: *
          *
        • - call {@link #fireEditorChangeEvent(PagePart, PagePart)}
        • *
        • - fire events to all registered listeners.
        • @@ -55,8 +54,7 @@ public class ActivePageTracker { protected PagePart activeEditor; /** - * Interface that must be implemented by listeners on activeEditorChange - * event. + * Interface that must be implemented by listeners on activeEditorChange event. * * @author dumoulin * @@ -72,9 +70,10 @@ public class ActivePageTracker { public void activeEditorChanged(PagePart oldEditor, PagePart newEditor); } + /** - * Constructor. The activeEditor will be set by the first TabFolder that - * will call TabFolderPart.setPage(). + * Constructor. + * The activeEditor will be set by the first TabFolder that will call TabFolderPart.setPage(). * * @param multiPartEditor */ @@ -91,8 +90,8 @@ public class ActivePageTracker { } /** - * Set the active editor with the specified editor. This will notify all - * registered listeners + * Set the active editor with the specified editor. + * This will notify all registered listeners * * @param editor */ @@ -162,8 +161,8 @@ public class ActivePageTracker { */ private void fireEditorChangeEvent(PagePart oldEditor, PagePart newEditor) { // Fire only if really change - // if(oldEditor == newEditor) - // return; +// if(oldEditor == newEditor) +// return; // Fire events to internal listeners for(IActiveEditorChangedListener listener : activeEditorChangedListeners) { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java index 7bf799422fc..289f7090396 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java @@ -26,8 +26,10 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.internal.dnd.IDropTarget; + /** - * This is a controler/part for an SWT Control. It is associated to a {@link IComponentModel}. This Part encapsulate a SWT Control. + * This is a controler/part for an SWT Control. It is associated to a {@link IComponentModel}. + * This Part encapsulate a SWT Control. * * @author dumoulin * @@ -66,7 +68,7 @@ public class ComponentPart extends PagePart implements IComponentPage { try { // Initialize it and create its controls. editorControl = createEditorPartControl(parent); - // attachListeners(editorControl, true); + // attachListeners(editorControl, true); } catch (PartInitException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage())); @@ -74,7 +76,8 @@ public class ComponentPart extends PagePart implements IComponentPage { } /** - * Create the controls required by the editor. Init the editor. + * Create the controls required by the editor. + * Init the editor. * * @param viewer * @param editorInput @@ -82,7 +85,8 @@ public class ComponentPart extends PagePart implements IComponentPage { * @return * @throws PartInitException */ - private Composite createEditorPartControl(Composite parentControl) throws PartInitException { + private Composite createEditorPartControl(Composite parentControl) + throws PartInitException { Composite editorParent = new Composite(parentControl, SWT.NONE); editorParent.setLayout(new FillLayout()); partModel.createPartControl(editorParent); @@ -95,14 +99,15 @@ public class ComponentPart extends PagePart implements IComponentPage { */ public void dispose() { - // detachListeners(editorControl, true); + // detachListeners(editorControl, true); // dispose the SWT root control editorControl.dispose(); } + /** - * As we are a final Tile, we should be the requested part. Return this - * TilePart. + * As we are a final Tile, we should be the requested part. + * Return this TilePart. * * @param toFind * @return @@ -112,8 +117,7 @@ public class ComponentPart extends PagePart implements IComponentPage { } /** - * Locates the part that intersects the given point and that have the - * expected type + * Locates the part that intersects the given point and that have the expected type * * @param toFind * @return @@ -125,7 +129,10 @@ public class ComponentPart extends PagePart implements IComponentPage { // Not found !! // The tile contains the position, but the type is not found. - throw new UnsupportedOperationException("Tile match the expected position '" + toFind + "' but there is no Tile of requested type '" + expectedTileType.getClass().getName() + "'"); + throw new UnsupportedOperationException("Tile match the expected position '" + + toFind + + "' but there is no Tile of requested type '" + + expectedTileType.getClass().getName() + "'"); } /** @@ -149,9 +156,10 @@ public class ComponentPart extends PagePart implements IComponentPage { return editorControl; } + /** - * This is a container method. Not necessary in Leaf Tile. TODO: change the - * interface. + * This is a container method. Not necessary in Leaf Tile. + * TODO: change the interface. * * @param draggedObject * @param sourcePart @@ -162,10 +170,11 @@ public class ComponentPart extends PagePart implements IComponentPage { return null; } + /** * Change the parent of the Tile. The parent is changed, and the control is - * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. Do not detach the Tile from its old - * parent. + * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. + * Do not detach the Tile from its old parent. * * @param newParent * The tilePart that should be used as part parent. @@ -189,20 +198,22 @@ public class ComponentPart extends PagePart implements IComponentPage { } } + /** - * Asks this part to take focus within the workbench. Set the focus on the - * active nested part if the part is a container. + * Asks this part to take focus within the workbench. + * Set the focus on the active nested part if the part is a container. */ public void setFocus() { editorControl.setFocus(); } + /** - * Synchronize the Part, and its children. PartMap contains a snapshot of - * the available part before the synchronization. After synchronization, - * unreachable parts should be marked "orphaned" (= no parent). Do nothing - * in this implementation, as we are a final leaf, and there is nothing to - * synchronize with the underlying model. + * Synchronize the Part, and its children. PartMap contains a snapshot of the available part before + * the synchronization. After synchronization, unreachable parts should be marked "orphaned" (= no + * parent). + * Do nothing in this implementation, as we are a final leaf, and there is nothing to synchronize + * with the underlying model. * * @param partMap */ @@ -210,9 +221,11 @@ public class ComponentPart extends PagePart implements IComponentPage { } + /** - * Garbage this part. The part is already marked as ORPHANED. It is not used - * anymore. It is already detached from its parent. + * Garbage this part. + * The part is already marked as ORPHANED. It is not used anymore. It is already detached + * from its parent. * */ public void garbage() { @@ -221,9 +234,10 @@ public class ComponentPart extends PagePart implements IComponentPage { getSashWindowContainer().getLifeCycleEventProvider().firePageClosedEvent(this); } + /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. + * Accept the provided visitor. + * Call the corresponding accept method in the visitor. * * @param visitor * @return @@ -233,7 +247,8 @@ public class ComponentPart extends PagePart implements IComponentPage { } /** - * Visit the children of this Tile. There is no child, so do nothing. + * Visit the children of this Tile. + * There is no child, so do nothing. * * @param visitor */ @@ -241,18 +256,20 @@ public class ComponentPart extends PagePart implements IComponentPage { return true; } + /** * Show item status. */ protected void showStatus() { - // System.out.println( "EditorTile: " - // + " disposed=" + editorControl.isDisposed() - // + ", visible=" + editorControl.isVisible() - // + ", garbState=" + garbageState - // + ", '" + editorPart.getTitle() - // + "', " + this); - - System.out.printf("ComponentPart: disposed=%-5b, visible=%-5b, garbState=%-10s, %s, %s\n", editorControl.isDisposed(), (editorControl.isDisposed() ? false : editorControl.isVisible()), garbageState, getPageTitle(), this); + // System.out.println( "EditorTile: " + // + " disposed=" + editorControl.isDisposed() + // + ", visible=" + editorControl.isVisible() + // + ", garbState=" + garbageState + // + ", '" + editorPart.getTitle() + // + "', " + this); + + System.out.printf("ComponentPart: disposed=%-5b, visible=%-5b, garbState=%-10s, %s, %s\n" + , editorControl.isDisposed(), (editorControl.isDisposed() ? false : editorControl.isVisible()), garbageState, getPageTitle(), this); } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java index bf356d466f1..06a6d33d006 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java @@ -14,6 +14,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; + /** * @author dumoulin */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IMultiEditorManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IMultiEditorManager.java index dc10a9ad6c0..5db7b40ed99 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IMultiEditorManager.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IMultiEditorManager.java @@ -13,33 +13,30 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IWorkbenchPartSite; + /** - * This interface allows EditorPart to access objects provided by the real - * editor. Implementation of this interface is provided to the {@link SashWindowsContainer} and used by {@link EditorPart}. The EditorPart - * will call {@link #getEditorInput()} and pass the result to input of the - * created nested IEditorPart. The site provided by {@link #getEditorSite()} is - * used to initialize a specific site for the nested IEditorPart. It is also - * used by the {@link SashWindowsContainer}. + * This interface allows EditorPart to access objects provided by the real editor. + * Implementation of this interface is provided to the {@link SashWindowsContainer} and used by {@link EditorPart}. + * The EditorPart will call {@link #getEditorInput()} and pass the result to input of the created nested IEditorPart. + * The site provided by {@link #getEditorSite()} is used to initialize a specific site for the nested IEditorPart. + * It is also used by the {@link SashWindowsContainer}. * * @author dumoulin */ public interface IMultiEditorManager { /** - * Get the EditorActionBarContributor for the editor associated to the - * specified model. + * Get the EditorActionBarContributor for the editor associated to the specified model. * * @param editorModel * @return * @throws MultiDiagramException */ - // public EditorActionBarContributor getActionBarContributor(Object - // editorModel); + // public EditorActionBarContributor getActionBarContributor(Object editorModel); /** * Fires a property changed event. @@ -47,7 +44,7 @@ public interface IMultiEditorManager { * @param propertyId * the id of the property that changed */ - // public void firePropertyChange(int propertyId); + // public void firePropertyChange(int propertyId); /** * Get the editor input associated to the main IMultiPageEditorPart. @@ -64,8 +61,8 @@ public interface IMultiEditorManager { public IWorkbenchPartSite getSite(); /** - * Get the IEditorSite associated to this MultiPageEditorPart. This return - * the same object as getSite(). + * Get the IEditorSite associated to this MultiPageEditorPart. + * This return the same object as getSite(). * * @return */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java index 0df25da7607..3dc169b67ad 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java @@ -13,14 +13,11 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; import org.eclipse.swt.widgets.Composite; /** - * Interface implemented by Part that can be parent of a Panel (Sashes or - * Folders). The interface allows to restrict the classes that can be parent of - * a Panel. For now, only {@link RootPart} and {@link SashPanelPart} can be - * parent of a Panel. + * Interface implemented by Part that can be parent of a Panel (Sashes or Folders). The interface allows to restrict the classes that can be parent of + * a Panel. For now, only {@link RootPart} and {@link SashPanelPart} can be parent of a Panel. * * @author dumoulin */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java index fa8a2cd3075..577c730a332 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java @@ -13,9 +13,10 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; + /** - * Visitor used to visit the hierarchy of Parts. Visit can be stopped by - * returning false from the visit() method. + * Visitor used to visit the hierarchy of Parts. + * Visit can be stopped by returning false from the visit() method. * * @author dumoulin * @@ -26,8 +27,7 @@ public interface IPartVisitor { * Accept the node of specified type. * * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. + * @return true if the visit should continue, false if the visit should be stopped. */ public boolean accept(RootPart tile); @@ -36,8 +36,7 @@ public interface IPartVisitor { * Accept the node of specified type. * * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. + * @return true if the visit should continue, false if the visit should be stopped. */ public boolean accept(SashPanelPart tile); @@ -45,8 +44,7 @@ public interface IPartVisitor { * Accept the node of specified type. * * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. + * @return true if the visit should continue, false if the visit should be stopped. */ public boolean accept(TabFolderPart folder); @@ -54,8 +52,7 @@ public interface IPartVisitor { * Accept the node of specified type. * * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. + * @return true if the visit should continue, false if the visit should be stopped. */ public boolean accept(TabItemPart tile); @@ -63,8 +60,7 @@ public interface IPartVisitor { * Accept the node of specified type. * * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. + * @return true if the visit should continue, false if the visit should be stopped. */ public boolean accept(EditorPart tile); @@ -72,9 +68,9 @@ public interface IPartVisitor { * Accept the node of specified type. * * @param componentPart - * @return true if the visit should continue, false if the visit should be - * stopped. + * @return true if the visit should continue, false if the visit should be stopped. */ public boolean accept(ComponentPart componentPart); + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java index 2cff40eeee8..49cc7b146fd 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java @@ -3,6 +3,8 @@ */ package org.eclipse.papyrus.infra.core.sasheditor.internal; + + /** * A visitor used to lookup a {@link TabFolderPart} by its raw model. * @@ -15,6 +17,7 @@ public class LookupFolderPartByRawModelVisitor extends PartVisitor { private TabFolderPart result; + public LookupFolderPartByRawModelVisitor(Object rawModel) { this.rawModel = rawModel; } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java index 705e888abd1..f995e51bf15 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java @@ -6,6 +6,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; import org.eclipse.ui.IEditorPart; + /** * A visitor used to lookup a PagePart by its IEditorPart. * @@ -18,6 +19,7 @@ public class LookupIPageByIEditorPartVisitor extends PartVisitor { private IPage result; + public LookupIPageByIEditorPartVisitor(IEditorPart editorPart) { this.editorPart = editorPart; } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java index a6d64983758..9f91cc18ef2 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java @@ -5,6 +5,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; + /** * A visitor used to lookup a PagePart from its raw model. * @@ -17,6 +18,7 @@ public class LookupModelPageVisitor extends PartVisitor { private IPage result; + public LookupModelPageVisitor(Object rawModel) { this.rawModel = rawModel; } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java index 8fd684b6554..2a6340074ce 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java @@ -13,6 +13,7 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; + /** * Exception thrown when a search or lookup fails. * @@ -20,6 +21,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; */ public class NotFoundException extends SashWindowsException { + /** * */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java index 1b754676e53..53e9f9b24e9 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java @@ -38,7 +38,8 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.internal.dnd.DragUtil; /** - * Papyrus wrapper for CTabFolder. Provides miscelaneous methods for dragging. + * Papyrus wrapper for CTabFolder. + * Provides miscelaneous methods for dragging. * Provides different fireEvents for: menu detected, pageChange, itemClosed. * TODO : add listeners mechanism to listen on events ? */ @@ -64,8 +65,8 @@ public class PTabFolder { }; /** - * Listener on control activated event. This event is used to set the tab as - * the active page. + * Listener on control activated event. + * This event is used to set the tab as the active page. */ private Listener activateListener = new Listener() { @@ -76,13 +77,14 @@ public class PTabFolder { }; /** - * Listen on menu detect. The event is forwarded. TODO [20100417] deprecated - * ? + * Listen on menu detect. + * The event is forwarded. + * TODO [20100417] deprecated ? */ private MenuDetectListener menuDetectListener = new MenuDetectListener() { public void menuDetected(MenuDetectEvent e) { - // Point globalPos = ((Control) e.widget).toDisplay(e.x, e.y); + // Point globalPos = ((Control) e.widget).toDisplay(e.x, e.y); Point globalPos = new Point(e.x, e.y); handleMenuDetect(globalPos, e); } @@ -107,12 +109,11 @@ public class PTabFolder { } /** - * Creates an empty container. Creates a CTabFolder with no style bits set, - * and hooks a selection listener which calls pageChange() whenever the selected tab changes. + * Creates an empty container. Creates a CTabFolder with no style bits set, and hooks a selection listener which calls pageChange() + * whenever the selected tab changes. * * @param parent - * The composite in which the container tab folder should be - * created; must not be null. + * The composite in which the container tab folder should be created; must not be null. * @return a new container */ private CTabFolder createContainer(Composite parent) { @@ -158,8 +159,7 @@ public class PTabFolder { } /** - * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder. - * attachListeners(Control, boolean) + * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder.attachListeners(Control, boolean) */ protected void attachListeners(CTabFolder theControl, boolean recursive) { @@ -173,21 +173,20 @@ public class PTabFolder { } /** - * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder. - * detachListeners(Control, boolean) + * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder.detachListeners(Control, boolean) */ private void detachListeners(Control theControl) { theControl.removeMenuDetectListener(menuDetectListener); // PresentationUtil.removeDragListener(theControl, dragListener); // theControl.removeDragDetectListener(dragDetectListener); - // theControl.removeListener(SWT.MouseUp, mouseUpListener); + // theControl.removeListener(SWT.MouseUp, mouseUpListener); theControl.removeListener(SWT.Activate, activateListener); } /** - * The context menu event has been fired, handle it. Actually, it is - * forwarded to the {@link EventsManager}. + * The context menu event has been fired, handle it. + * Actually, it is forwarded to the {@link EventsManager}. * * @param displayPos * @param e @@ -199,9 +198,8 @@ public class PTabFolder { } /** - * Called when drag start. From here, DragUtil.performDrag() is called, - * which start the dragging process. DragUtil.performDrag() will contains - * the tabFolder or the dragged tab. + * Called when drag start. From here, DragUtil.performDrag() is called, which start the + * dragging process. DragUtil.performDrag() will contains the tabFolder or the dragged tab. */ protected void handleDragStarted(Point displayPos, Event e) { @@ -217,27 +215,28 @@ public class PTabFolder { } /** - * Handle menu detect. TODO Connect menu staff here. + * Handle menu detect. + * TODO Connect menu staff here. * * @param displayPos * @param e */ private void handleMenuDetect(Point displayPos, MenuDetectEvent e) { - // if(isOnBorder(displayPos)) { - // return; - // } + // if(isOnBorder(displayPos)) { + // return; + // } CTabItem tab = getItem(displayPos); listenersManager.fireMenuDetectEvent(tab, e); } /** - * Handle folder reselected. A folder is reselected by clicking on the - * active tabs, on the page or on the empty tabs area. In each case a - * PageChangeEvent is fired. When mouse click happen on the empty area, or - * on the page, the last selected tabs is used. Used to switch the Active - * tab when user click on already opened tabs. + * Handle folder reselected. + * A folder is reselected by clicking on the active tabs, on the page or on the empty tabs area. + * In each case a PageChangeEvent is fired. + * When mouse click happen on the empty area, or on the page, the last selected tabs is used. + * Used to switch the Active tab when user click on already opened tabs. * * @param displayPos * @param e @@ -255,9 +254,8 @@ public class PTabFolder { } /** - * Returns true iff the given point is on the border of the folder. By - * default, double-clicking, context menus, and drag/drop are disabled on - * the folder's border. + * Returns true iff the given point is on the border of the folder. By default, double-clicking, + * context menus, and drag/drop are disabled on the folder's border. * * @param toTest * a point (display coordinates) @@ -304,17 +302,16 @@ public class PTabFolder { } /** - * Get the rectangle bounding the item, in the parent coordinates. Utility - * method. Can be moved somewhere else. + * Get the rectangle bounding the item, in the parent coordinates. Utility method. Can be moved somewhere else. */ public Rectangle getItemBounds(CTabItem item) { return Geometry.toDisplay(item.getParent(), item.getBounds()); } /** - * Fire a page closed event. This event is fired when the close item is - * pressed. The item is not closed yet. By default, the item is closed after - * the event. The item is not closed if event.doit is set to false. + * Fire a page closed event. This event is fired when the close item is pressed. The item is not closed yet. By default, the item is closed after + * the event. The item is not closed if event.doit is + * set to false. * */ protected void fireItemClosed(CTabFolderEvent event, int pageIndex) { @@ -356,8 +353,7 @@ public class PTabFolder { * Get the index of the draggedObject * * @param draggedObject - * draggedObject should be of type CTabFolder or CTabItem (as - * provided by handleDragStarted()) + * draggedObject should be of type CTabFolder or CTabItem (as provided by handleDragStarted()) */ static public int getDraggedObjectTabIndex(Object draggedObject) { if(draggedObject instanceof CTabItem) { @@ -389,7 +385,8 @@ public class PTabFolder { } /** - * Get the event manager. The event manager can be used to listen to events. + * Get the event manager. + * The event manager can be used to listen to events. * * @return */ @@ -420,7 +417,8 @@ public class PTabFolder { } /** - * Internal implementations. Implements a list of listeners. + * Internal implementations. + * Implements a list of listeners. * * @author dumoulin * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java index ffef343925b..b8a18ab5ac3 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java @@ -23,22 +23,19 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; /** - * This class represent a leaf part that is a part containing an editor or a - * component. + * This class represent a leaf part that is a part containing an editor or a component. * * @author dumoulin */ public abstract class PagePart extends AbstractPart implements IPage { - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ + /** Raw model associated to this part. We store it because the PartModel do not provide it */ protected Object rawModel; /** Parent part of this Part */ protected TabFolderPart parent; + /** * Constructor. * @@ -50,18 +47,18 @@ public abstract class PagePart extends AbstractPart implements IPage { this.rawModel = rawModel; } + /** * @return the parent */ - public TabFolderPart getParent() { + protected TabFolderPart getParent() { return parent; } /** - * Orphan this node. The parent is set to null, but control is left - * unchanged. The node can be reattached with reparent(). Change garbage - * state to {@link GarbageState.ORPHANED}. This method as no effect if the - * Page has already been reparented. + * Orphan this node. The parent is set to null, but control is left unchanged. + * The node can be reattached with reparent(). Change garbage state to {@link GarbageState.ORPHANED}. + * This method as no effect if the Page has already been reparented. * * @see * @return the parent @@ -75,7 +72,8 @@ public abstract class PagePart extends AbstractPart implements IPage { } /** - * Mark this Page as UNCHANGED. The PAge should be in the COLLECTED state. + * Mark this Page as UNCHANGED. + * The PAge should be in the COLLECTED state. * * @see * @return the parent @@ -100,8 +98,8 @@ public abstract class PagePart extends AbstractPart implements IPage { abstract boolean visit(IPartVisitor visitor); /** - * Locates the part that intersects the given point and that have the - * expected type. For a leaf, return the leaf if it is of the expected type. + * Locates the part that intersects the given point and that have the expected type. + * For a leaf, return the leaf if it is of the expected type. * * @param position * @param expectedTileType @@ -130,16 +128,16 @@ public abstract class PagePart extends AbstractPart implements IPage { abstract public Control getControl(); /** - * reparent this Part with the specified new parent. The part is marked as - * reparented. + * reparent this Part with the specified new parent. + * The part is marked as reparented. * * @param parent */ abstract public void reparent(TabFolderPart parent); /** - * Add the tree of parts starting from this part. As we are a leaf, add - * itself only. + * Add the tree of parts starting from this part. + * As we are a leaf, add itself only. * * @param partMap */ @@ -158,8 +156,9 @@ public abstract class PagePart extends AbstractPart implements IPage { } /** - * Return a title for this part. This title can be used by parent to be - * shown in tabs ... To be implemented by subclasses. + * Return a title for this part. This title can be used by parent to be shown + * in tabs ... + * To be implemented by subclasses. * * @return The title or null. */ @@ -169,7 +168,8 @@ public abstract class PagePart extends AbstractPart implements IPage { /** * Return a icon for this part. This title can be used by parent to be shown - * in tabs ... To be implemented by subclasses. + * in tabs ... + * To be implemented by subclasses. * * @return The icon or null. */ @@ -183,10 +183,9 @@ public abstract class PagePart extends AbstractPart implements IPage { public void refreshTab() { getParent().refreshPageTab(this); } - /** - * Set focus on the SWT control associated to this PagePart. Used by the - * ActivePageTracker. + * Set focus on the SWT control associated to this PagePart. + * Used by the ActivePageTracker. */ abstract public void setFocus(); @@ -196,8 +195,8 @@ public abstract class PagePart extends AbstractPart implements IPage { abstract public void garbage(); /** - * Return true if the part is associated to the specified rawModel. Return - * false otherwise. + * Return true if the part is associated to the specified rawModel. + * Return false otherwise. * * @param realModel * @return @@ -206,4 +205,5 @@ public abstract class PagePart extends AbstractPart implements IPage { return this.rawModel == realModel; } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java index 69aed4c2c5c..b694efe5659 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java @@ -6,6 +6,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage; import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageVisitor; + /** * A wrapper used to let the provided public visitor use the internal visitor to * visit {@link ComponentPart} and {@link EditorPart}. diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java index 8c19ef3719e..af72d4eb4fa 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java @@ -16,12 +16,12 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; import java.util.ArrayList; import java.util.List; + /** - * This class contains lists of parts, regardless of the part parents. There are - * two lists: one for the pane Parts and one for the Page Parts (leafs). This - * class is used when refreshing the SashContainer: a new instance is created - * and filled with existing parts. Then the list is carried in each pane refresh - * method. + * This class contains lists of parts, regardless of the part parents. + * There are two lists: one for the pane Parts and one for the Page Parts (leafs). + * This class is used when refreshing the SashContainer: a new instance is created + * and filled with existing parts. Then the list is carried in each pane refresh method. * * @author cedric dumoulin */ @@ -35,8 +35,8 @@ public class PartLists { private List createdPages /* = new ArrayList() */; /** - * Search for a Part associated to the specified newModel. Return the part - * or null if none is found. + * Search for a Part associated to the specified newModel. + * Return the part or null if none is found. * * @param rawModel * @return @@ -51,8 +51,8 @@ public class PartLists { } /** - * Find the pane part for the specified rawModel. Return the found part or - * null + * Find the pane part for the specified rawModel. + * Return the found part or null * * @param rawModel * The raw model for which a part is lookup. @@ -110,7 +110,7 @@ public class PartLists { * @return a valid active page, or null if none exists. */ public PagePart getFirstValidPage() { - + for(PagePart part : pageParts) { if(!part.isOrphaned()) return part; @@ -138,8 +138,8 @@ public class PartLists { } /** - * Add a PagePart to the list of created Page. This is called from the - * TabFolder when a new page is created. + * Add a PagePart to the list of created Page. + * This is called from the TabFolder when a new page is created. * * @param modelPart */ @@ -152,4 +152,5 @@ public class PartLists { } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java index 74851810727..6fac9b0eb36 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java @@ -13,6 +13,7 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; + /** * Visitor implementation allowing to visit the hierarchy of Parts. * @@ -28,6 +29,7 @@ public class PartVisitor implements IPartVisitor { */ public boolean accept(TabFolderPart part) { + if(acceptTabFolderPart(part)) { // Visit the children return part.visitChildren(this); @@ -108,6 +110,7 @@ public class PartVisitor implements IPartVisitor { return false; } + // ---------------------------------------------- /** @@ -164,4 +167,5 @@ public class PartVisitor implements IPartVisitor { return true; } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java index ec0437d6bed..2c2c251666d 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java @@ -17,22 +17,20 @@ import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelM import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; /** - * Part used as root. This is the one with no parent and no model. This class is - * intended for local use only. + * Part used as root. This is the one with no parent and no model. This class is intended for local + * use only. * * @author dumoulin * * @param T - * Common ancestor for the model provided for the sash windows by the - * application. This is the type used externally by the application. - * Sash implementation don't use this type, it just carry it to ask - * for the appropriate wrapper. Concrete implementation can specify a - * type. + * Common ancestor for the model provided for the sash windows by the application. + * This is the type used externally by the application. Sash implementation don't use this type, + * it just carry it to ask for the appropriate wrapper. Concrete implementation can specify + * a type. */ @SuppressWarnings("restriction") public class RootPart extends AbstractPart implements IPanelParent { @@ -45,10 +43,7 @@ public class RootPart extends AbstractPart implements IPanelParent { */ private AbstractPanelPart child; - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ + /** Raw model associated to this part. We store it because the PartModel do not provide it */ private Object rawModel; /** @@ -59,15 +54,15 @@ public class RootPart extends AbstractPart implements IPanelParent { } /** - * Create the SWT controls. This Root as no control. Create the child part - * and call the same method on the child. + * Create the SWT controls. + * This Root as no control. Create the child part and call the same method on the child. */ public void createPartControl(Composite parent) { this.container = parent; Object rawModel = getContentProvider().getRootModel(); // Create child part - // child = createChildPart(rawModel); + // child = createChildPart(rawModel); } /** @@ -85,9 +80,10 @@ public class RootPart extends AbstractPart implements IPanelParent { return container; } + /** - * Create the part for the specified child model. The controls are also - * builds. + * Create the part for the specified child model. + * The controls are also builds. * * TODO: delegate to sashContainer. * @@ -107,9 +103,10 @@ public class RootPart extends AbstractPart implements IPanelParent { createdPart = new SashPanelPart(this, (ISashPanelModel)model, rawModel); } else { // error - throw new IllegalArgumentException("Can't create child part for model of type '" + model.getClass().getName() + "'"); - // TODO: Return an error Part showing the exception instead of - // throwing it ? + throw new IllegalArgumentException("Can't create child part for model of type '" + + model.getClass().getName() + + "'"); + // TODO: Return an error Part showing the exception instead of throwing it ? } // Create controls @@ -154,9 +151,8 @@ public class RootPart extends AbstractPart implements IPanelParent { Object rawModel = getContentProvider().getRootModel(); // Check if old child exist - // If exist, check if the current part is associated to the checked - // model - // + // If exist, check if the current part is associated to the checked model + // if(child != null) { // If the tile is already for the model, there is nothing to do. if(child.isPartFor(rawModel)) { @@ -183,8 +179,7 @@ public class RootPart extends AbstractPart implements IPanelParent { } /** - * Set the child. If a child already exist at the specified index, it is - * lost. + * Set the child. If a child already exist at the specified index, it is lost. * * @param newTile */ @@ -228,16 +223,15 @@ public class RootPart extends AbstractPart implements IPanelParent { return null; } - // /** - // * Locates the part that intersects the given point and that have the - // expected type - // * - // * @param toFind - // * @return - // */ - // public AbstractPart findPartAt(Point toFind, Class tileType) { - // return child.findPartAt(toFind, tileType); - // } + // /** + // * Locates the part that intersects the given point and that have the expected type + // * + // * @param toFind + // * @return + // */ + // public AbstractPart findPartAt(Point toFind, Class tileType) { + // return child.findPartAt(toFind, tileType); + // } /** * @@ -249,16 +243,12 @@ public class RootPart extends AbstractPart implements IPanelParent { return null; } - // /** - // * @see - // org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart#getDropTarget(java.lang.Object, - // org.eclipse.papyrus.infra.core.sasheditor.sash.TabFolderPart, - // org.eclipse.swt.graphics.Point) - // */ - // public IDropTarget getDropTarget(Object draggedObject, TabFolderPart - // sourcePart, Point position) { - // return child.getDropTarget(draggedObject, sourcePart, position); - // } + // /** + // * @see org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart#getDropTarget(java.lang.Object, org.eclipse.papyrus.infra.core.sasheditor.sash.TabFolderPart, org.eclipse.swt.graphics.Point) + // */ + // public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { + // return child.getDropTarget(draggedObject, sourcePart, position); + // } /** * Do nothing. This node can't be orphaned @@ -291,8 +281,8 @@ public class RootPart extends AbstractPart implements IPanelParent { } /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. + * Accept the provided visitor. + * Call the corresponding accept method in the visitor. * * @param visitor * @return @@ -318,7 +308,11 @@ public class RootPart extends AbstractPart implements IPanelParent { * Show tile status. */ protected void showStatus() { - org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("rootPart (1)" + ", disposed=" + container.isDisposed() + ", visible=" + container.isVisible() + ", " + this); + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("rootPart (1)" + + ", disposed=" + container.isDisposed() + + ", visible=" + container.isVisible() + + ", " + this); } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsListener.java new file mode 100644 index 00000000000..869a446b8a9 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsListener.java @@ -0,0 +1,62 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener; + + +/** + * Interface to be implemented by listeners on {@link SashWindowsContainer} life + * cycle events. + * + * @author cedric dumoulin + * + */ +public interface SashContainerEventsListener extends IPageChangedListener { + + /** + * + * @param page + * The page firing the event. + */ + public void pageOpened(IPage page); + + /** + * + * @param page + * The page firing the event. + */ + public void pageClosed(IPage page); + + /** + * The specify page is activated. It become the current active page. + * + * @param page + * The page firing the event. + */ + public void pageActivated(IPage page); + + /** + * The specify page is deactivated. + * + * @param page + * The page firing the event. + */ + public void pageDeactivated(IPage page); + + /** + * + * @param page + * The page firing the event. + */ + public void pageAboutToBeOpened(IPage page); + + /** + * + * @param page + * The page firing the event. + */ + public void pageAboutToBeClosed(IPage page); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java index c26e5279504..721f9d30c14 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java @@ -6,16 +6,14 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal; import java.util.ArrayList; import java.util.List; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashContainerEventsListener; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; /** - * A class managing events of the {@link SashWindowsContainer}. This class - * dispatch events fired by the {@link SashWindowsContainer} to any listeners + * A class managing events of the {@link SashWindowsContainer}. + * This class dispatch events fired by the {@link SashWindowsContainer} to any listeners * implementing {@link SashContainerEventsProvider}. * * @author cedric dumoulin - * + * */ public class SashContainerEventsProvider { @@ -43,9 +41,9 @@ public class SashContainerEventsProvider { listeners.remove(listener); } + /** * Notify all listener with event. - * * @param newEditor */ public void firePageOpenedEvent(PagePart page) { @@ -57,7 +55,6 @@ public class SashContainerEventsProvider { /** * Notify all listener with event. - * * @param newEditor */ public void firePageClosedEvent(PagePart page) { @@ -69,7 +66,6 @@ public class SashContainerEventsProvider { /** * Notify all listener with event. - * * @param newEditor */ public void firePageAboutToBeOpenedEvent(PagePart page) { @@ -81,7 +77,6 @@ public class SashContainerEventsProvider { /** * Notify all listener with event. - * * @param newEditor */ public void firePageAboutToBeClosedEvent(PagePart page) { @@ -93,7 +88,6 @@ public class SashContainerEventsProvider { /** * Notify all listener with event. - * * @param newEditor */ public void firePageActivatedEvent(PagePart page) { @@ -105,7 +99,6 @@ public class SashContainerEventsProvider { /** * Notify all listener with event. - * * @param newEditor */ public void firePageDeactivatedEvent(PagePart page) { 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 314c08d19e0..b78f2e2a241 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 @@ -26,9 +26,10 @@ import org.eclipse.ui.internal.dnd.DragUtil; import org.eclipse.ui.internal.dnd.IDropTarget; /** - * Controller for a sash panel. A sash panel contain 2 children. It shows them - * in two windows separated by a sash. Implementation use one model, a {@link ISashPanelModel}. This model encapsulate the real model which is of an - * unknown type. + * Controller for a sash panel. + * A sash panel contain 2 children. It shows them in two windows separated by a sash. + * Implementation use one model, a {@link ISashPanelModel}. This model encapsulate the real model which + * is of an unknown type. * * * @author dumoulin @@ -45,16 +46,10 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { /** Interface to the model */ protected ISashPanelModel model; - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ + /** Raw model associated to this part. We store it because the PartModel do not provide it */ private Object rawModel; - /** - * Ordered set of currently shown diagrams (a left and right child, or upper - * and lower) TODO rename as children - */ + /** Ordered set of currently shown diagrams (a left and right child, or upper and lower) TODO rename as children */ protected AbstractPanelPart[] currentChildParts = new AbstractPanelPart[2]; /** @@ -63,8 +58,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { private ReplaceableSashForm container; /** - * Direction of the sash: SWT.HORIZONTAL or SWT.VERTICAL. Default = - * SWT.HORIZONTAL + * Direction of the sash: SWT.HORIZONTAL or SWT.VERTICAL. Default = SWT.HORIZONTAL */ private int sashDirection = SWT.HORIZONTAL; @@ -86,8 +80,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Fill the provided part map with this parts and recursively call children - * to fillin. + * Fill the provided part map with this parts and recursively call children to fillin. * * @param partMap */ @@ -100,8 +93,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Create local control, and the tree of children (TileParts AND controls). - * Create this TilePart control, and then Tile childs of this TilePart. + * Create local control, and the tree of children (TileParts AND controls). Create this TilePart control, and then Tile childs of this TilePart. * * @param parent * @return Control @@ -109,8 +101,8 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { public void createPartControl(Composite parent) { createControl(parent); - // activate(); - // createChildrenControl(); + // activate(); + // createChildrenControl(); } /** @@ -123,11 +115,10 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Create the part for the specified child model. The controls are NOT - * build. + * Create the part for the specified child model. + * The controls are NOT build. * - * TODO: delegate to sashContainer, remove duplication from here and - * RootPart. + * TODO: delegate to sashContainer, remove duplication from here and RootPart. * * @param rootPart * @param partModel @@ -145,19 +136,20 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { createdPart = new SashPanelPart(this, (ISashPanelModel)model, rawModel); } else { // error - throw new IllegalArgumentException("Can't create child part for model of type '" + model.getClass().getName() + "'"); - // TODO: Return an error Part showing the exception instead of - // throwing it ? + throw new IllegalArgumentException("Can't create child part for model of type '" + + model.getClass().getName() + + "'"); + // TODO: Return an error Part showing the exception instead of throwing it ? } return createdPart; } /** - * Create the part for the specified child model. The controls are build. + * Create the part for the specified child model. + * The controls are build. * - * TODO: delegate to sashContainer, remove duplication from here and - * RootPart. + * TODO: delegate to sashContainer, remove duplication from here and RootPart. * * @param rootPart * @param partModel @@ -171,6 +163,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { return createdPart; } + /** * Get the sash container. * @@ -183,8 +176,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Change the parent of this method. Reparent the Tile and the control. - * Normally, the control already exists. + * Change the parent of this method. Reparent the Tile and the control. Normally, the control already exists. * */ @Override @@ -204,8 +196,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Orphan this node, and children. The parent is set to null, but control is - * left unchanged. The node can be reattached with reparent(). + * Orphan this node, and children. The parent is set to null, but control is left unchanged. The node can be reattached with reparent(). * * @see * @return the parent @@ -256,11 +247,11 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { throw new NotFoundException("Can't find a part at '" + toFind + "'"); + } /** - * Locates the part that intersects the given point and that have the - * expected type + * Locates the part that intersects the given point and that have the expected type * * @param toFind * Position in Display coordinate. @@ -286,6 +277,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } } + /** * Return true if this sash is vertical, false otherwise. */ @@ -324,8 +316,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Return true if the Part is for the specified real model. Return false - * otherwise. + * Return true if the Part is for the specified real model. Return false otherwise. * * @param realModel * The raw model to check @@ -386,9 +377,8 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { Object newModel = model.getChildren().get(childIndex); // Check if old child exist - // If exist, check if the current part is associated to the checked - // model - // + // If exist, check if the current part is associated to the checked model + // AbstractPanelPart currentChildPart = currentChildParts[childIndex]; if(currentChildPart != null) { // If the tile is already for the model, there is nothing to do. @@ -432,8 +422,7 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Set the provided child at the specified index. If a child already exist - * at the specified index, it is lost. The controls are set accordingly + * Set the provided child at the specified index. If a child already exist at the specified index, it is lost. The controls are set accordingly * * @param newTile * @param childIndex @@ -444,8 +433,8 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. + * Accept the provided visitor. + * Call the corresponding accept method in the visitor. * * @param visitor * @return @@ -471,10 +460,15 @@ public class SashPanelPart extends AbstractPanelPart implements IPanelParent { } /** - * Show tile status. Used for debug purpose + * Show tile status. + * Used for debug purpose */ protected void showStatus() { - org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("sash[" + currentChildParts.length + "]:" + ", disposed=" + container.isDisposed() + ", visible=" + container.isVisible() + ", garbState=" + garbageState + ", " + this); + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("sash[" + currentChildParts.length + "]:" + + ", disposed=" + container.isDisposed() + + ", visible=" + container.isVisible() + + ", garbState=" + garbageState + + ", " + this); } } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainer.java new file mode 100644 index 00000000000..ace2eb7ad34 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainer.java @@ -0,0 +1,1003 @@ +/***************************************************************************** + * 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.internal; + +import static org.eclipse.papyrus.infra.core.sasheditor.Activator.log; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.util.Geometry; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IComponentModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageVisitor; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.internal.DragCursors; +import org.eclipse.ui.internal.dnd.DragUtil; +import org.eclipse.ui.internal.dnd.IDragOverListener; +import org.eclipse.ui.internal.dnd.IDropTarget; + + +/** + * Main entry class of the SashWindows system. + * This class allows to have a multitab window with sashes. + * The class require a ContentProvider describing the content to be shown. + * + * @author dumoulin + */ +@SuppressWarnings("restriction") +public class SashWindowsContainer implements ISashWindowsContainer { + + /** + * The content provider describing the sashes, folders and tabs. + */ + private ISashWindowsContentProvider contentProvider; + + /** + * The manager used to get Main editor properties like Site, ActionBars, ... + */ + private IMultiEditorManager multiEditorManager; + + /** + * Tracker tracking the current active page. The tracker also disconnect last active page and connect + * the new one. + */ + private ActivePageTracker activePageTracker; + + /** + * Event provider firing Pages life cycle events to registered listeners. Inner parts call the fireXxxEvents + * when appropriate. + */ + private SashContainerEventsProvider lifeCycleEventProvider; + + /** + * The part used as root. We use an extra class as root in order to separate the code dedicated to + * ITilePart. + */ + private RootPart rootPart; + + /** + * The SWT container associated to this part. This is generally the container of the + * parent. + */ + private Composite container; + + /** + * The drop target. + */ + protected DropTarget dropTarget; + + /** A flag that indicates that the model is being synchronized. */ + private AtomicBoolean isRefreshing = new AtomicBoolean(false); + + /** + * The cached value of the menu manager, if any. + */ + private MenuManager folderTabMenuManager; + + /** + * Constructor. + * Build a Container without IEditor management. Trying to add a EditorPart will result in an Exception. + * The ContentProvider should not contain IEditorModel. + */ + public SashWindowsContainer() { + this(null); + } + + /** + * Constructor. + * Build a container with EditorPart management. The container will allow to add EditorPart + * (and thus IEditorModel to the ContentProvider). + * + * @param multiEditorManager + * The manager allowing to use {@link IEditorModel} in the model. + * If null, the sash will not render IEditorModel. + * + */ + public SashWindowsContainer(IMultiEditorManager multiEditorManager) { + this.multiEditorManager = multiEditorManager; + activePageTracker = new ActivePageTracker(); + + if(multiEditorManager != null) { + // Add listener on activePageChange. + // This listener will take in charge editor services switching. + activePageTracker.addActiveEditorChangedListener(new ActiveEditorServicesSwitcher(multiEditorManager.getEditorSite())); + } + + // Life cycle event provider + lifeCycleEventProvider = new SashContainerEventsProvider(); + } + + /** + * @return the contentProvider + */ + protected ISashWindowsContentProvider getContentProvider() { + // Content provider should have been set. + assert (contentProvider != null); + // Double check for developement + if(contentProvider == null) + throw new IllegalStateException("ContentProvider should be set before calling any method requiring it."); + + return contentProvider; + } + + /** + * Set the content provider describing the sashes, folders and tabs. + * + * @param contentProvider + * the contentProvider to set + */ + public void setContentProvider(ISashWindowsContentProvider contentProvider) { + this.contentProvider = contentProvider; + } + + /** + * Creates control associated to this Container. + * This method should be called when the parent is build. + * + * @param parent + * The parent in which the editor should be created; must not be null. + */ + public void createPartControl(Composite parent) { + this.container = parent; + + rootPart = createRootPart(); + // Create the tree of tile part. + rootPart.createPartControl(container); + // Create children + refreshTabs(); + // Set selection + selectPage(lookupFirstValidPage()); + + // postCreatePartControl(); + // TODO reactivate next + initDrag(container); + // activate(); + } + + /** + * Create the root part for the model. + */ + private RootPart createRootPart() { + RootPart part = new RootPart(this); + return part; + } + + /** + * Notifies this page container that the specified page has been activated. This method + * is called after the current tabs has been changed, either by refreshing the tabs, or by a user + * UI action. + * This method just set correctly the active page value in the Container, and fire pageChanged events if needed. + * It does not change the selected page in the Part. + * + * Propagate the event to activePageTracker. + * + * @param childPart + */ + protected void pageChanged(PagePart childPart) { + activePageTracker.setActiveEditor(childPart); + lifeCycleEventProvider.firePageActivatedEvent(childPart); + } + + /** + * Notifies this page container that a pageChanged event has been fired by one swt Control. + * This method is usually called after the user selects a different tab. + * + * The method record the new active folder in the ContentProvider, and calls {@link #pageChanged(PagePart)}. + * + * @param childPart + */ + protected void pageChangedEvent(PagePart childPart) { + + // Check if it is really a change before changing the model (which can throw change event) + // The folder model change is done before the tracker fires the listeners, like this + // listeners can check the model. + if(getActivePage() == childPart) + return; + + contentProvider.setCurrentFolder(childPart.getParent().getRawModel()); + pageChanged(childPart); + } + + /** + * Set the active page. The current active page will be the specified page. + * Do not record the new active folder in the ContentProvider + * + * The method record the new CurrentFolder, and calls {@link #pageChanged(PagePart)}. + * + * @param childPart + */ + protected void setActivePage(PagePart childPart) { + pageChanged(childPart); + } + + /** + * A change has happen in one of the inner parts. Relay the event. + * This method is called by inner parts whenever the event happen in one of the part. + * It collects and relay the firePropertyChange(int propertyId) calls from the inner IEditor. + * + * @param propertyId + */ + protected void firePropertyChange(int propertyId) { + // For now, we do nothing with this event. + } + + /** + * Create the part for the specified newModel. + * + * @param parent + * The parent of the created part. + * @param partModel + * The model for which a part should be created. + * @return + */ + protected PagePart createPagePart(TabFolderPart parent, IPageModel partModel, Object rawModel) { + + + if(partModel instanceof IEditorModel) { + // Check if we can use IEditorModel + if(multiEditorManager == null) + throw new IllegalArgumentException("Container can't accept IEditorModel as no IMultiEditorManager is set. Please set a IMultiEditorManager."); + + return new EditorPart(parent, (IEditorModel)partModel, rawModel, multiEditorManager); + } else if(partModel instanceof IComponentModel) { + return new ComponentPart(parent, (IComponentModel)partModel, rawModel); + } else { + // Return a default part + } + + // TODO return a default part showing an error instead. + throw new IllegalArgumentException("No Part found for the model '" + rawModel + "'"); + } + + /** + * Get the active page. + * + * @return + */ + private PagePart getActivePage() { + return activePageTracker.getActiveEditor(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#getActiveEditor() + * @return + * + */ + public IEditorPart getActiveEditor() { + PagePart pagePart = getActivePage(); + if(pagePart instanceof EditorPart) + return ((EditorPart)pagePart).getIEditorPart(); + else + return null; + } + + /** + * Get the active page public API. + * + * @return + */ + public IPage getActiveSashWindowsPage() { + return getActivePage(); + } + + /** + * Get the list of visible IPages. The visible IPages are the one that have there diagram area + * visible. + * + * @return + */ + public List getVisiblePages() { + CollectVisiblePageVisitor visitor = new CollectVisiblePageVisitor(); + + rootPart.visit(visitor); + + return visitor.getVisiblePages(); + } + + /** + * Get the list of visible IPages. The visible IPages are the one that have there diagram area + * visible. + * + * @return + */ +// public List getVisibleIEditorPages() { +// CollectVisiblePageVisitor visitor = new CollectVisiblePageVisitor( IEditorPage.class); +// +// rootPart.visit(visitor); +// +// return visitor.getVisiblePages(); +// } + + /** + * Get the list of visible IPages. The visible IPages are the one that have there diagram area + * visible. + * + * @return + */ + public List getVisibleIEditorParts() { + CollectVisibleIEditorPart visitor = new CollectVisibleIEditorPart(); + rootPart.visit(visitor); + + return visitor.getVisiblePages(); + } + + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#setFocus() + * + */ + public void setFocus() { + setFocus(getActivePage()); + } + + /** + * Sets focus to the control for the given page. If the page has an editor, + * this calls its setFocus() method. Otherwise, this calls setFocus on the control for the page. + * + * @param pageIndex + * the index of the page + */ + private void setFocus(PagePart part) { + if(part != null) + part.setFocus(); + } + + + /** + * Refresh the tabs. + * Is we are already currently refreshing, simply return. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#refreshTabs() + * + */ + public void refreshTabs() { + + // Check if we arent already refreshing + if(isRefreshing.compareAndSet(false, true)) { + try { + refreshTabsInternal(); + } finally { + isRefreshing.set(false); + } + } else { + log.warn("refresh inside refresh !"); + } + + } + + /** + * Refresh the tab of the page, (i.e the name and icon in the page's tab). + * + * @param page The page for which the name and icon should be refreshed. + */ + public void refreshPageTab(IPage page) { + if( page instanceof PagePart) + { + ((PagePart)page).refreshTab(); + } + else + { + // TODO : lookup for the corresponding PagePart, and call refresh. + + } + } + /** + * Real implementation of refreshTab. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#refreshTabs() + * + */ + private void refreshTabsInternal() { + // System.out.println("start synchronize2() ------------------------"); + // showTilesStatus(); + + // Get the currently selected folder + PagePart oldActivePage = getActivePage(); + + // Do refresh + container.setRedraw(false); + // Create map of parts + // PartMap partMap = new PartMap(); + PartLists garbageMaps = new PartLists(); + rootPart.fillPartMap(garbageMaps); + + // Synchronize parts + rootPart.synchronize2(garbageMaps); + + + // Remove orphaned parts (no more used) + garbageMaps.garbage(); + + // set active page if needed + setActivePage(checkAndGetActivePage(oldActivePage, garbageMaps)); + + // Reenable SWT and force layout + container.setRedraw(true); + container.layout(true, true); + // System.out.println("end synchronize2() ------------------------"); + // showTilesStatus(); + } + + /** + * Select the specified page in the Parts. The specified page will becomes the active one. + * Appropriate events are fired. + * This is the programatic counterpart of selecting a page in the UI. + * If the provided page is null, do nothing. + * + * @param page + * The page to select or null. + */ + protected void selectPage(PagePart page) { + if(page == null) + return; + TabFolderPart folder = page.getParent(); + folder.setActiveEditor(page); + } + + /** + * Select the specified page in the Parts. The specified page will becomes the active one. + * Appropriate events are fired. + * This is the programatic counterpart of selecting a page in the UI. + * If the provided page is null, do nothing. + * + * @param page + * The page to select or null. The IPage should + * be an instance previously returned by the SashContainer. + */ + public void selectPage(IPage page) { + if(page == null) + return; + + // check if we are a correct instance. + if(!(page instanceof PagePart)) + return; + + selectPage((PagePart)page); + } + + /** + * Lookup the {@link IPage} used to render the specified rawModel. + * + * @param rawModel + * The model for which the IPage is requested. + * If the model is not rendered, return null; + * + * @return The corresponding IPage or null if not found. + */ + public IPage lookupModelPage(Object rawModel) { + // Use a visitor to lookup the first IPage + LookupModelPageVisitor visitor = new LookupModelPageVisitor(rawModel); + rootPart.visit(visitor); + return visitor.result(); + } + + /** + * Lookup the {@link IPage} used to render the specified IEditorPart. + * + * @param editor + * The IEditorPart for which the IPage is requested. + * If the IEditorPart is not rendered, return null; + * + * @return The corresponding IPage or null if not found. + */ + public IPage lookupIPageByIEditorPart(IEditorPart editor) { + // Use a visitor to lookup the first IPage + LookupIPageByIEditorPartVisitor visitor = new LookupIPageByIEditorPartVisitor(editor); + rootPart.visit(visitor); + return visitor.result(); + } + + /** + * Check if the oldActivePage still alive, and set it if needed. + * If the oldActivePage is null, set an active page if one exist. + * If the oldActivePage still alive, let it as the active one. If it is + * disposed, get arbitrarily an active page if one exist. + * + * @param oldActivePage + * @param partLists + * @param garbageMaps + * @return A valid active page or null if none exists. + */ + private PagePart checkAndGetActivePage(PagePart oldActivePage, PartLists partLists) { + + // Check if there is a created page + PagePart activePage = partLists.getFirstCreatedPage(); + if(activePage != null) + return activePage; + + // Check oldActivePage validity (in case it has been deleted) + if(oldActivePage != null && !(oldActivePage.isOrphaned() || oldActivePage.isUnchecked())) + return oldActivePage; + + // Get an active page if any + return lookupFirstValidPage(); + } + + /** + * Lookup for a valid active Page. Return null if none is found. + * TODO Use a visitor to implements this method. + * + * @return + */ + private PagePart lookupFirstValidPage() { + // First get a list of active editors + PartLists garbageMaps = new PartLists(); + rootPart.fillPartMap(garbageMaps); + return garbageMaps.getFirstValidPage(); + } + + /** + * Set a {@link MenuManager} used to manage a contextual menu that is shown on the tabs area of the folders. + * + * @param menuManager + * The {@link MenuManager} used to create the menu on the tab area. + */ + public void setFolderTabMenuManager(MenuManager menuManager) { + this.folderTabMenuManager = menuManager; + // Set the MenuManager in each existing folder. + // Use a visitor. + SetFolderTabMenuVisitor visitor = new SetFolderTabMenuVisitor(menuManager); + rootPart.visit(visitor); + } + + /** + * @return the menuManager + */ + protected MenuManager getFolderTabMenuManager() { + return folderTabMenuManager; + } + + /** + * Show the status of the different Tiles composing the sash system. + * Used for debug purpose. + */ + public void showTilesStatus() { + ShowPartStatusVisitor visitor = new ShowPartStatusVisitor(); + rootPart.visit(visitor); + } + + + /** + * Visit all the Pages (IEditorPage and IComponentPage), allowing to access to the public interface. + */ + public void visit(IPageVisitor pageVisitor) { + PageVisitorWrapper visitor = new PageVisitorWrapper(pageVisitor); + rootPart.visit(visitor); + } + + /** + * Visit the Part associated to the container. This method visibility is protected in order to be able to access it + * from junit tests. + * It is not intended to be used by public API or from outside. + */ + protected void visit(IPartVisitor visitor) { + rootPart.visit(visitor); + } + + /* ***************************************************** */ + /* Drag and Drop methods */ + /* ***************************************************** */ + + /** + * + */ + private void initDrag(Composite container) { + DragUtil.addDragTarget(container, dragOverListener); + + } + + IDragOverListener dragOverListener = new IDragOverListener() { + + /** + * + * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, + * org.eclipse.swt.graphics.Rectangle) + */ + public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) { + // TODO remove the cast by changing the method. Only folder can be source and target + final TabFolderPart sourcePart = (TabFolderPart)rootPart.findPart(draggedObject); // (ITilePart) draggedObject; + // Compute src tab index + // TODO move that and previous in the sender of drag event. Use a class containing both as draggedObject. + final int srcTabIndex = PTabFolder.getDraggedObjectTabIndex(draggedObject); + +// System.out.println("drag to position=" + position); + Rectangle containerDisplayBounds = DragUtil.getDisplayBounds(container); + AbstractPanelPart targetPart = null; + + // Check if the cursor is inside the container + if(containerDisplayBounds.contains(position)) { + + if(rootPart != null) { + targetPart = (AbstractPanelPart)rootPart.findPart(position); + // System.out.println("targetPart=" + targetPart + // + ", position=" + position + // + "container.toControl(position)=" + container.toControl(position)); + } + + if(targetPart != null) { + final Control targetControl = targetPart.getControl(); + + final Rectangle targetBounds = DragUtil.getDisplayBounds(targetControl); + + int side = Geometry.getClosestSide(targetBounds, position); + int distance = Geometry.getDistanceFromEdge(targetBounds, position, side); + + // Reserve the 5 pixels around the edge of the part for the drop-on-edge cursor + // Check if the target can handle the drop. + if(distance >= 5) { + // Otherwise, ask the part if it has any special meaning for this drop location + // TODO remove cast; change return type of findPart() + IDropTarget target = targetPart.getDropTarget(draggedObject, (TabFolderPart)sourcePart, position); + if(target != null) { + return target; + } + } else { + // We are on the boarder, try to drop on the parent + // Warning : the parent could be the rootPart +// System.out.println("DropTarget near the border"); + } + // + if(distance > 30) { + side = SWT.CENTER; + } + // + // // If the part doesn't want to override this drop location then drop on the edge + // + // // A "pointless drop" would be one that will put the dragged object back where it started. + // // Note that it should be perfectly valid to drag an object back to where it came from -- however, + // // the drop should be ignored. + // + @SuppressWarnings("unused") + boolean pointlessDrop = false; + + if(sourcePart == targetPart) { + pointlessDrop = true; + } + + return createDropTarget(sourcePart, srcTabIndex, side, side, targetPart); + } + } else { + // Cursor is outside the container +// System.out.println("Outside container bounds"); + // This will be used to create a new Window. + // We only allow dropping into a stack, not creating one + // if (differentWindows) + // return null; + + int side = Geometry.getClosestSide(containerDisplayBounds, position); + + boolean pointlessDrop = false; + int cursor = Geometry.getOppositeSide(side); + + if(pointlessDrop) { + side = SWT.NONE; + } + + return createDropTarget(sourcePart, srcTabIndex, side, cursor, null); + } + return null; + } + + }; + + /** + * Create the drop target + */ + private DropTarget createDropTarget(final TabFolderPart sourcePart, int srcTabIndex, int side, int cursor, AbstractPart targetPart) { + if(dropTarget == null) { + dropTarget = new DropTarget(sourcePart, srcTabIndex, side, cursor, targetPart); + } else { + dropTarget.setTarget(sourcePart, srcTabIndex, side, cursor, targetPart); + } + return dropTarget; + } + + /** + * Class implementing methods required by drop targets. + */ + protected class DropTarget implements IDropTarget { + + int count = 0; + + int cursor = SWT.TOP; + + private int side; + + private AbstractPanelPart targetPart; + + private int srcTabIndex; + + private TabFolderPart sourcePart; + + /** + * Constructor. + */ + public DropTarget(TabFolderPart sourcePart, int srcTabIndex, int cursor, int side, AbstractPart targetPart) { + this.cursor = cursor; + this.side = side; + this.sourcePart = sourcePart; + this.srcTabIndex = srcTabIndex; + this.targetPart = (AbstractPanelPart)targetPart; + } + + public void setTarget(TabFolderPart sourcePart, int srcTabIndex, int cursor, int side, AbstractPart targetPart) { + this.cursor = cursor; + this.side = side; + this.sourcePart = sourcePart; + this.srcTabIndex = srcTabIndex; + this.targetPart = (AbstractPanelPart)targetPart; + } + + /** + * A folder is dropped. + * + * @see org.eclipse.ui.internal.dnd.IDropTarget#drop() + */ + public void drop() { + // @TODO remove next cast + if(side == SWT.CENTER) { // Add to target folder + contentProvider.movePage(sourcePart.getPartModel(), srcTabIndex, ((TabFolderPart)targetPart).getPartModel(), -1); + } else { // Create a new folder + contentProvider.createFolder(sourcePart.getPartModel(), srcTabIndex, ((TabFolderPart)targetPart).getPartModel(), side); + } + } + + /** + * Return the cursor used during drag. + * + * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor() + */ + public Cursor getCursor() { +// System.out.println(SashWindowsContainer.this.getClass().getSimpleName() + ".getCursor()-" + count++); + return DragCursors.getCursor(DragCursors.positionToDragCursor(cursor)); + + } + + public Rectangle getSnapRectangle() { +// System.out.println(SashWindowsContainer.this.getClass().getSimpleName() + ".getSnapRectangle(" + "sourcePart=" + sourcePart + ", targetPart=" + targetPart + ", side=" + side); + Rectangle targetDisplayBounds; + + if(targetPart != null) { + targetDisplayBounds = DragUtil.getDisplayBounds(targetPart.getControl()); + } else { + // targetBounds = DragUtil.getDisplayBounds(getParent()); + targetDisplayBounds = DragUtil.getDisplayBounds(container); + } + + if(side == SWT.CENTER || side == SWT.NONE) { + return targetDisplayBounds; + } + + int distance = Geometry.getDimension(targetDisplayBounds, !Geometry.isHorizontal(side)); + + return Geometry.getExtrudedEdge(targetDisplayBounds, (int)(distance * getDockingRatio(sourcePart, targetPart)), side); + } + + protected float getDockingRatio(AbstractPart dragged, AbstractPart target) { + return 0.5f; + } + + } + + + /** + * @return the lifeCycleEventProvider + */ + protected SashContainerEventsProvider getLifeCycleEventProvider() { + return lifeCycleEventProvider; + } + + /** + * Add a listener on pageChanged event. + * This implementation delegates to the internal PageTracker. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param pageChangedListener + * + */ + public void addPageChangedListener(IPageChangedListener pageChangedListener) { + activePageTracker.addPageChangedListener(pageChangedListener); + } + + /** + * Remove a listener on pageChanged event. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param pageChangedListener + * + */ + public void removePageChangedListener(IPageChangedListener pageChangedListener) { + activePageTracker.removePageChangedListener(pageChangedListener); + } + + /** + * Add a listener on Page LifeCycle events. + * This implementation delegates to the internal PageTracker. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param listener + * + */ + public void addLifeCycleListener(SashContainerEventsListener listener) { + lifeCycleEventProvider.addListener(listener); + } + + /** + * Remove a listener on Page LifeCycle events. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param listener + * + */ + public void removeLifeCycleListener(SashContainerEventsListener listener) { + lifeCycleEventProvider.removeListener(listener); + } + + /* ***************************************************** */ + /* Internal Visitors */ + /* ***************************************************** */ + + + /** + * Inner class. + * A visitor setting the {@link MenuManager} on each folder. + */ + private class SetFolderTabMenuVisitor extends PartVisitor { + + + private MenuManager menuManager; + + /** + * Constructor. + * + * @param menuManager + */ + public SetFolderTabMenuVisitor(MenuManager menuManager) { + this.menuManager = menuManager; + } + + /** + * Set the menu if the visited node is a folder. + */ + @Override + public boolean accept(TabFolderPart part) { + part.setFolderTabMenuManager(menuManager); + return true; + } + + } + + /** + * Inner class. + * A visitor used to collect all visible page in the sashcontainer. + * A visible page is a page whose the diagram area is visible. + */ + private class CollectVisiblePageVisitor extends PartVisitor { + + private List visiblePages = new ArrayList(); + + private Class expectedClass; + + /** + * Constructor. + * + * @param menuManager + */ + public CollectVisiblePageVisitor() { + + } + + /** + * Constructor. + * + * @param menuManager + */ + @SuppressWarnings("unused") + public CollectVisiblePageVisitor(Class expectedClass) { + this.expectedClass = expectedClass; + } + + /** + * Get the result list. + * @param + * @return + */ + @SuppressWarnings("unchecked") + public List getVisiblePages() { + return (List)visiblePages; + } + + /** + * Set the menu if the visited node is a folder. + */ + @Override + public boolean accept(TabFolderPart part) { + + IPage page = part.getVisiblePagePart(); + if( part != null) { + if( expectedClass != null && expectedClass.isInstance(page)) { + visiblePages.add(page); + } + else { + visiblePages.add(page); + } + + } + + return true; + } + + } + + /** + * Inner class. + * A visitor used to collect all visible page in the sashcontainer. + * A visible page is a page whose the diagram area is visible. + */ + private class CollectVisibleIEditorPart extends PartVisitor { + + private List visiblePages = new ArrayList(); + /** + * Constructor. + * + * @param menuManager + */ + public CollectVisibleIEditorPart() { + + } + + /** + * Get the result list. + * @param + * @return + */ + public List getVisiblePages() { + return visiblePages; + } + + /** + * Set the menu if the visited node is a folder. + */ + @Override + public boolean accept(TabFolderPart part) { + + IPage page = part.getVisiblePagePart(); + if( page != null && page instanceof IEditorPage ) { + IEditorPage editorPage = (IEditorPage) page; + visiblePages.add(editorPage.getIEditorPart()); + + } + // continue searching + return true; + } + + } + + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java index 0f259d58e67..9c4544cb0e9 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java @@ -13,6 +13,7 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; + /** * Main Exception from the SashWindowsSystem. * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java index 0297ddf1637..d37534960ed 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java @@ -13,9 +13,9 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.core.sasheditor.internal; + /** - * Visitor used to show the status of the different Tiles composing the sash - * system. + * Visitor used to show the status of the different Tiles composing the sash system. * * @author dumoulin * @@ -33,7 +33,7 @@ public class ShowPartStatusVisitor extends PartVisitor { public boolean accept(RootPart tile) { indent(); tile.showStatus(); - // System.out.println( "root:" + tile ); + // System.out.println( "root:" + tile ); level++; super.accept(tile); level--; @@ -45,7 +45,7 @@ public class ShowPartStatusVisitor extends PartVisitor { */ private void indent() { if(level < 1) { - // error + //error return; } @@ -63,7 +63,7 @@ public class ShowPartStatusVisitor extends PartVisitor { public boolean accept(SashPanelPart tile) { indent(); tile.showStatus(); - // System.out.println( "sash:" + tile ); + // System.out.println( "sash:" + tile ); level++; super.accept(tile); level--; @@ -77,7 +77,7 @@ public class ShowPartStatusVisitor extends PartVisitor { public boolean accept(TabFolderPart tile) { indent(); tile.showStatus(); - // System.out.println( "folder:" + tile ); + // System.out.println( "folder:" + tile ); level++; super.accept(tile); level--; @@ -91,7 +91,7 @@ public class ShowPartStatusVisitor extends PartVisitor { public boolean accept(EditorPart tile) { indent(); tile.showStatus(); - // System.out.println( "editor:" + tile ); + // System.out.println( "editor:" + tile ); level++; super.accept(tile); level--; @@ -105,11 +105,12 @@ public class ShowPartStatusVisitor extends PartVisitor { public boolean accept(ComponentPart tile) { indent(); tile.showStatus(); - // System.out.println( "editor:" + tile ); + // System.out.println( "editor:" + tile ); level++; super.accept(tile); level--; return true; } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java index 7636c55d0b3..5943e334026 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java @@ -21,7 +21,6 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.util.Geometry; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.AbstractTabFolderPart; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; @@ -51,14 +50,13 @@ import org.eclipse.ui.internal.dnd.IDropTarget; * Extends MultiPageEditor to inherit methods implementations. * * @param T - * Common ancestor for the model provided for the sash windows by the - * application. This is the type used externally by the application. - * Sash implementation don't use this type, it just carry it to ask - * for the appropriate wrapper. Concrete implementation can specify a - * type. + * Common ancestor for the model provided for the sash windows by the application. + * This is the type used externally by the application. Sash implementation don't use this type, + * it just carry it to ask for the appropriate wrapper. Concrete implementation can specify + * a type. * - * TODO : be more precise for the generic type ? TODO : Listen to the - * page change event, and call setActivePage(). + * TODO : be more precise for the generic type ? + * TODO : Listen to the page change event, and call setActivePage(). */ @SuppressWarnings("restriction") public class TabFolderPart extends AbstractTabFolderPart { @@ -69,22 +67,13 @@ public class TabFolderPart extends AbstractTabFolderPart { /** Interface to the model */ protected ITabFolderModel partModel; - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ + /** Raw model associated to this part. We store it because the PartModel do not provide it */ private Object rawModel; - /** - * The wrapper around the CTabFolder. This represent the SWT control - * associated to this part. - */ + /** The wrapper around the CTabFolder. This represent the SWT control associated to this part. */ protected PTabFolder pTabFolder; - /** - * Ordered set of currently shown diagrams (list of their models) TODO - * remove - */ + /** Ordered set of currently shown diagrams (list of their models) TODO remove */ protected TabPartList currentTabItems = new TabPartList(); /** The drop target associated to this folderPart */ @@ -95,6 +84,7 @@ public class TabFolderPart extends AbstractTabFolderPart { */ private MouseHoverTracker mouseHoverTracker; + /** * Listener on DragOver event. */ @@ -106,9 +96,8 @@ public class TabFolderPart extends AbstractTabFolderPart { * org.eclipse.swt.graphics.Rectangle) */ public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) { - // System.out.println(TabFolderPart.this.getClass().getSimpleName() - // + ".drag()"); - // System.out.println(this + ".drag()"); + // System.out.println(TabFolderPart.this.getClass().getSimpleName() + ".drag()"); +// System.out.println(this + ".drag()"); return null; } }; @@ -119,23 +108,22 @@ public class TabFolderPart extends AbstractTabFolderPart { private PTabFolder.IPTabFolderListener cTabFolderEventListener = new PTabFolder.IPTabFolderListener() { public void contextMenuDetectEvent(CTabItem tab, Event event) { - // System.out.println("contextMenuDetect()"); +// System.out.println("contextMenuDetect()"); } /** * The close cross has been pressed. Remove the corresponding tab. {@inheritDoc} */ public void itemClosedEvent(CTabFolderEvent event, int pageIndex) { - // System.out.println("itemClosedEvent()"); +// System.out.println("itemClosedEvent()"); // TODO: call appropriate method (to be determine) - // model.removeTab(pageIndex); - // getSashWindowContainer().getContentProvider().removeTab(model, - // pageIndex); + // model.removeTab(pageIndex); + // getSashWindowContainer().getContentProvider().removeTab(model, pageIndex); getContentProvider().removePage(partModel, pageIndex); } public void menuDetectEvent(CTabItem tab, MenuDetectEvent event) { - // System.out.println("menuDetectEvent()"); +// System.out.println("menuDetectEvent()"); } /** @@ -166,7 +154,7 @@ public class TabFolderPart extends AbstractTabFolderPart { /** * Get the associated model. */ - public ITabFolderModel getPartModel() { + protected ITabFolderModel getPartModel() { return partModel; } @@ -181,8 +169,8 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Deactivate this part. Unregistered from required service. Do not dispose - * the part. + * Deactivate this part. + * Unregistered from required service. Do not dispose the part. */ private void deactivate() { // Listen to page changes @@ -191,8 +179,7 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Fill the provided part map with this parts and recursively call children - * to fillin. + * Fill the provided part map with this parts and recursively call children to fillin. * * @param partMap */ @@ -206,37 +193,36 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Creates the control tree associated to this part. Create the control for - * this part, and eventually recursively call the method for the childs, if - * any. + * Creates the control tree associated to this part. + * Create the control for this part, and eventually recursively call the method for the childs, if any. * */ @Override public void createPartControl(Composite parent) { createControl(parent); - // createPages(); + // createPages(); // model.addChangeListener(modelListener); // model.activate(); activate(); } /** - * Add a new page at the end of pages. A new tab is created for the page, - * and the page control is created. + * Add a new page at the end of pages. A new tab is created for the page, and + * the page control is created. * * @param pageModel * @param index */ - // private void addPage(Object pageModel) - // { - // int index = currentTabItems.size(); - // createTabItem(pageModel, index); - // } + // private void addPage(Object pageModel) + // { + // int index = currentTabItems.size(); + // createTabItem(pageModel, index); + // } /** - * Create the control for this Part. Does not create children. This method - * is called by the parent after this folder is created. + * Create the control for this Part. Does not create children. + * This method is called by the parent after this folder is created. * */ public void createControl(Composite parent) { @@ -249,24 +235,22 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Init the menuManager after the control has been created. Get the {@link MenuManager} from the {@link SashWindowsContainer}. Set it to this - * folder if it is not null. + * Init the menuManager after the control has been created. + * Get the {@link MenuManager} from the {@link SashWindowsContainer}. Set it to this folder if it + * is not null. */ private void initMenuManager() { MenuManager menuManager = getSashWindowContainer().getFolderTabMenuManager(); - if(menuManager != null) { + if(menuManager != null) + { setFolderTabMenuManager(menuManager); } - + } /** - * Set a {@link MenuManager} used to manage a contextual menu that is shown - * on the tabs area of this folder. - * - * @param menuManager - * The {@link MenuManager} used to create the menu on the tab - * area. + * Set a {@link MenuManager} used to manage a contextual menu that is shown on the tabs area of this folder. + * @param menuManager The {@link MenuManager} used to create the menu on the tab area. */ public void setFolderTabMenuManager(MenuManager menuManager) { Composite folderControl = getControl(); @@ -274,6 +258,7 @@ public class TabFolderPart extends AbstractTabFolderPart { folderControl.setMenu(menu); } + /** * The page has change. Propagate the event to the container. * @@ -282,8 +267,7 @@ public class TabFolderPart extends AbstractTabFolderPart { @Override protected void pageChange(int newPageIndex) { - // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ - // newPageIndex +")"); + // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ newPageIndex +")"); // Do nothing if out of range. if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) return; @@ -292,15 +276,14 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * An event signaling that the selected page is changed has been caught. - * Propagate the event to the container. + * An event signaling that the selected page is changed has been caught. Propagate the event to + * the container. * * @param newPageIndex */ protected void pageChangedEvent(int newPageIndex) { - // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ - // newPageIndex +")"); + // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ newPageIndex +")"); // Do nothing if out of range. if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) return; @@ -319,6 +302,7 @@ public class TabFolderPart extends AbstractTabFolderPart { deactivate(); + // getControl().dispose(); pTabFolder.dispose(); } @@ -330,6 +314,7 @@ public class TabFolderPart extends AbstractTabFolderPart { DragUtil.addDragTarget(container, dragOverListener); } + /** * Get the associated CTabFolder */ @@ -346,8 +331,8 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * The MultiPageEditor implementation of this IWorkbenchPart method sets focus on the active nested - * editor, if there is one. + * The MultiPageEditor implementation of this IWorkbenchPart method sets focus on + * the active nested editor, if there is one. *

          * Subclasses may extend or reimplement. *

          @@ -357,8 +342,8 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Sets focus to the control for the given page. If the page has an editor, - * this calls its setFocus() method. Otherwise, this calls setFocus on the control for the page. + * Sets focus to the control for the given page. If the page has an editor, this calls its setFocus() method. Otherwise, this calls + * setFocus on the control for the page. * * @param pageIndex * the index of the page @@ -372,9 +357,8 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Set the active page of this multi-page editor to the page that contains - * the given editor part. This method has no effect of the given editor part - * is not contained in this multi-page editor. + * Set the active page of this multi-page editor to the page that contains the given editor part. This method has no effect of the given editor + * part is not contained in this multi-page editor. * * @param editorPart * the editor part @@ -392,8 +376,8 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Return the part containing specified point. Normally return this part, - * because the caller has already determine that this contain the part. + * Return the part containing specified point. Normally return this part, because the caller has + * already determine that this contain the part. * */ @Override @@ -402,8 +386,7 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Locates the part that intersects the given point and that have the - * expected type + * Locates the part that intersects the given point and that have the expected type * * @param toFind * @return @@ -447,10 +430,9 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Get the visible PagePart (from the Container point of view). The visible - * PagePart is the one that has its diagram area visible. From the folder - * point of view, this is the active PagePart. - * + * Get the visible PagePart (from the Container point of view). + * The visible PagePart is the one that has its diagram area visible. + * From the folder point of view, this is the active PagePart. * @return */ public PagePart getVisiblePagePart() { @@ -460,7 +442,7 @@ public class TabFolderPart extends AbstractTabFolderPart { } return null; } - + /** * Find the part associated to the provided control. * @@ -478,6 +460,7 @@ public class TabFolderPart extends AbstractTabFolderPart { return null; } + /** * * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPanelPart#getDropTarget(java.lang.Object, @@ -500,8 +483,7 @@ public class TabFolderPart extends AbstractTabFolderPart { if(tabUnderPointer == null) { Rectangle titleArea = pTabFolder.getTabArea(); - // If we're dragging over the title area, treat this as a drop in - // the last + // If we're dragging over the title area, treat this as a drop in the last // tab position. if(titleArea.contains(position) && pTabFolder.getTabFolder().getItemCount() > 0) { int dragOverIndex = pTabFolder.getTabFolder().getItemCount(); @@ -512,8 +494,7 @@ public class TabFolderPart extends AbstractTabFolderPart { return null; } - // If we are unable to compute the bounds for this tab, then - // ignore the drop + // If we are unable to compute the bounds for this tab, then ignore the drop Rectangle lastTabBounds = lastTab.getBounds(); if(lastTabBounds.isEmpty()) { return null; @@ -522,32 +503,24 @@ public class TabFolderPart extends AbstractTabFolderPart { // if (dragStart >= 0) { // dragOverIndex--; // - // return createDropTarget( sourcePart, lastTabBounds, - // dragOverIndex); - // // return new StackDropResult(lastTabBounds, new - // Integer(dragOverIndex)); + // return createDropTarget( sourcePart, lastTabBounds, dragOverIndex); + // // return new StackDropResult(lastTabBounds, new Integer(dragOverIndex)); // } - // Make the drag-over rectangle look like a tab at the end of - // the tab region. - // We don't actually know how wide the tab will be when it's - // dropped, so just + // Make the drag-over rectangle look like a tab at the end of the tab region. + // We don't actually know how wide the tab will be when it's dropped, so just // make it 3 times wider than it is tall. - // titleArea is in Display coordinate, lastTabBounds in parent - // coordinate + // titleArea is in Display coordinate, lastTabBounds in parent coordinate Rectangle dropRectangle = titleArea; dropRectangle.x = dropRectangle.x + lastTabBounds.x + lastTabBounds.width; dropRectangle.width = 3 * dropRectangle.height; return createDropTarget(sourcePart, sourceIndex, dropRectangle, dragOverIndex); - // return new StackDropResult(dropRectangle, new - // Integer(dragOverIndex)); + // return new StackDropResult(dropRectangle, new Integer(dragOverIndex)); } else { - // If the closest side is the side with the tabs, consider this - // a stack operation. - // Otherwise, let the drop fall through to whatever the default - // behavior is + // If the closest side is the side with the tabs, consider this a stack operation. + // Otherwise, let the drop fall through to whatever the default behavior is Rectangle displayBounds = DragUtil.getDisplayBounds(pTabFolder.getControl()); int closestSide = Geometry.getClosestSide(displayBounds, position); if(closestSide == pTabFolder.getTabFolder().getTabPosition()) { @@ -587,8 +560,7 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Class implementing methods required by drop targets. Drop target use when - * the drop occur on one of the thumbnail of the folder. + * Class implementing methods required by drop targets. Drop target use when the drop occur on one of the thumbnail of the folder. */ protected class DropTarget implements IDropTarget { @@ -649,23 +621,20 @@ public class TabFolderPart extends AbstractTabFolderPart { * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor() */ public Cursor getCursor() { - // System.out.println(TabFolderPart.this.getClass().getSimpleName() - // + ".getCursor()-" + count++); + // System.out.println(TabFolderPart.this.getClass().getSimpleName() + ".getCursor()-" + count++); return DragCursors.getCursor(DragCursors.positionToDragCursor(cursor)); } public Rectangle getSnapRectangle() { - // System.out.println(TabFolderPart.this.getClass().getSimpleName() - // + ".getSnapRectangle()-" + count); + // System.out.println(TabFolderPart.this.getClass().getSimpleName() + ".getSnapRectangle()-" + count); return snapRectangle; } } /** - * Orphan this node. The parent is set to null, but control is left - * unchanged. The node can be reattached with reparent(). + * Orphan this node. The parent is set to null, but control is left unchanged. The node can be reattached with reparent(). * * @see * @return the parent @@ -711,8 +680,7 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Return true if the Part is for the specified real model. Return false - * otherwise. + * Return true if the Part is for the specified real model. Return false otherwise. * * @param realModel * The raw model to check @@ -727,30 +695,29 @@ public class TabFolderPart extends AbstractTabFolderPart { * * @return */ - public Object getRawModel() { + protected Object getRawModel() { return rawModel; } /** * Refresh the tab of this page (I.e the name and icon in the tab). * - * @param page - * The page to be refreshed + * @param page The page to be refreshed */ - public void refreshPageTab(PagePart page) { + public void refreshPageTab( PagePart page) { TabItemPart itemPart = currentTabItems.getByPagePart(page); - if(itemPart == null) + if(itemPart==null) return; - + itemPart.refreshTabDecorations(); } - + /** - * Synchronize the TabFolder with the models. The Tabs order is fixed and - * can't be moved. So, we move the associated ITilepart if needed. For each - * existing Tab, compare its model and the requested model. Synchronize if - * necessary. If their is more new model, add new Tab If their is less - * newModel, remove unused Tabs. + * Synchronize the TabFolder with the models. + * The Tabs order is fixed and can't be moved. So, we move the associated ITilepart if needed. + * For each existing Tab, compare its model and the requested model. Synchronize if necessary. + * If their is more new model, add new Tab + * If their is less newModel, remove unused Tabs. * * @param partLists */ @@ -812,24 +779,23 @@ public class TabFolderPart extends AbstractTabFolderPart { activePageIndex = currentTabItems.size() - 1; } + folder.setRedraw(true); - // folder.setSelection(activePageIndex); + // folder.setSelection(activePageIndex); folder.redraw(); - if(activePageIndex >= 0 && activePageIndex < folder.getItemCount()) { - // System.err.println("setActivePage(" + activePageIndex + ") : " + - // this); + if(activePageIndex >= 0) { + // System.err.println("setActivePage(" + activePageIndex + ") : " + this); // Set the activeTab has visible. // Do it here because otherwise the active tab could be not visible. - // This come from an undefined bug setting the tab.isVisible(false) - // in some case. + // This come from an undefined bug setting the tab.isVisible(false) in some case. folder.getItem(activePageIndex).getControl().setVisible(true); setActivePage(activePageIndex); } else { // Check if there is item in the CTabFolder. // If true, we have a trouble if(getTabFolder().getItemCount() > 0) { - // System.err.println("Active page not set while synchronizing !"); + // System.err.println("Active page not set while synchronizing !"); // We have items, but none is selected. // Select the first one. if(getTabFolder().getSelectionIndex() < 0) { @@ -837,14 +803,14 @@ public class TabFolderPart extends AbstractTabFolderPart { } } } - // folder.update(); - // folder.showSelection(); + // folder.update(); + // folder.showSelection(); } /** - * Remove the specified tabItem. Also call appropriate remove() method on - * the tabItem. + * Remove the specified tabItem. + * Also call appropriate remove() method on the tabItem. * * @param curTab */ @@ -854,10 +820,9 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Create a new TabItem associated to the part corresponding to the - * specified newModel. The TabItem is created at the specified index. The - * associated parts is searched in the existingParts or created if none is - * found. + * Create a new TabItem associated to the part corresponding to the specified newModel. + * The TabItem is created at the specified index. + * The associated parts is searched in the existingParts or created if none is found. * * @param existingParts * List of existing parts. @@ -877,44 +842,42 @@ public class TabFolderPart extends AbstractTabFolderPart { // No part found, create one modelPart = createChildPart(newModel); if(modelPart != null) { - existingParts.addCreatedPage(modelPart); - // Attach it to the tabItem - newTab = new TabItemPart(this, modelPart, index); - } + existingParts.addCreatedPage(modelPart); + // Attach it to the tabItem + newTab = new TabItemPart(this, modelPart, index); + } } // Add to the list of items. if(newTab != null) { - currentTabItems.add(index, newTab); + currentTabItems.add(index, newTab); } } - // /** - // * Create a new TabItem and associated part corresponding to the specified - // newModel. - // * The TabItem is created at the specified index. - // * The associated parts is created. - // * - // * @param existingParts List of existing parts. - // * @param newModel - // * @param index - // * @param i - // */ - // private void createTabItem(Object newModel, int index) { - // TabItemPart newTab; + // /** + // * Create a new TabItem and associated part corresponding to the specified newModel. + // * The TabItem is created at the specified index. + // * The associated parts is created. + // * + // * @param existingParts List of existing parts. + // * @param newModel + // * @param index + // * @param i + // */ + // private void createTabItem(Object newModel, int index) { + // TabItemPart newTab; // - // PagePart modelPart = createChildPart( newModel ); - // // Attach it to the tabItem - // newTab = new TabItemPart(this, modelPart, index); + // PagePart modelPart = createChildPart( newModel ); + // // Attach it to the tabItem + // newTab = new TabItemPart(this, modelPart, index); // - // // Add to the list of items. - // currentTabItems.add(index, newTab); - // } + // // Add to the list of items. + // currentTabItems.add(index, newTab); + // } /** - * Instruct the specified tabItem to use the new model. Check if a part - * already exist for the model and use it if any. Otherwise create a new - * Part. + * Instruct the specified tabItem to use the new model. Check if a part already exist for the model + * and use it if any. Otherwise create a new Part. * * @param curTab * @param existingParts @@ -936,10 +899,10 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Factory method to create a new Part for the specified newModel. The - * method should always return a valid Part. In case of error while creating - * the requested part, the method should return a default part, maybe - * showing the encountered error. The control for the child is created. + * Factory method to create a new Part for the specified newModel. + * The method should always return a valid Part. In case of error while creating the requested part, + * the method should return a default part, maybe showing the encountered error. + * The control for the child is created. * * @param newModel * @return The new part @@ -950,20 +913,19 @@ public class TabFolderPart extends AbstractTabFolderPart { IPageModel partModel = getPartModel().createChildSashModel(newModel); if(partModel != null) { - // Delegate part creation to the container. This allow the container to - // provide appropriate - // objects not available from the part. - PagePart newPart = getSashWindowContainer().createPagePart(this, partModel, newModel); - // Create control. - // Fire events before and after - getSashWindowContainer().getLifeCycleEventProvider().firePageAboutToBeOpenedEvent(newPart); - newPart.createPartControl(getControl()); - getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart); - - return newPart; - } - - return null; + // Delegate part creation to the container. This allow the container to provide appropriate + // objects not available from the part. + PagePart newPart = getSashWindowContainer().createPagePart(this, partModel, newModel); + // Create control. + // Fire events before and after + getSashWindowContainer().getLifeCycleEventProvider().firePageAboutToBeOpenedEvent(newPart); + newPart.createPartControl(getControl()); + getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart); + + return newPart; + } + // Use exception ? + return null; } /** @@ -1004,20 +966,20 @@ public class TabFolderPart extends AbstractTabFolderPart { System.out.println(); // - // System.out.printf("tabs.ctrl :" ); - // for( TabItemPart tab : currentModels) - // { - // System.out.printf( "%10s |", tab.childPart.getControl()); - // } - // System.out.println(); - - // - // System.out.printf("tab.editor:" ); - // for( TabItemPart tab : currentModels) - // { - // System.out.printf( "%10s |", tab.childPart.getIEditorPart()); - // } - // System.out.println(); + // System.out.printf("tabs.ctrl :" ); + // for( TabItemPart tab : currentModels) + // { + // System.out.printf( "%10s |", tab.childPart.getControl()); + // } + // System.out.println(); + + // + // System.out.printf("tab.editor:" ); + // for( TabItemPart tab : currentModels) + // { + // System.out.printf( "%10s |", tab.childPart.getIEditorPart()); + // } + // System.out.println(); // System.out.printf("tabs %2d :", currentTabItems.size()); @@ -1032,19 +994,20 @@ public class TabFolderPart extends AbstractTabFolderPart { * Show tile status. */ protected void showStatus() { - // System.out.println( "tabfolder[" + currentModels.size() + "]:" - // + ", disposed=" + getCTabFolder().isDisposed() - // + ", visible=" + getCTabFolder().isVisible() - // + ", garbState=" + garbageState - // + ", " + this); + // System.out.println( "tabfolder[" + currentModels.size() + "]:" + // + ", disposed=" + getCTabFolder().isDisposed() + // + ", visible=" + getCTabFolder().isVisible() + // + ", garbState=" + garbageState + // + ", " + this); CTabFolder ctrl = getTabFolder(); - System.out.printf("tabfolder[%2d]: disposed=%-5b, visible=%-5b, garbState=%-10s, %s\n", currentTabItems.size(), ctrl.isDisposed(), (ctrl.isDisposed() ? false : getTabFolder().isVisible()), garbageState, this); + System.out.printf("tabfolder[%2d]: disposed=%-5b, visible=%-5b, garbState=%-10s, %s\n" + , currentTabItems.size(), ctrl.isDisposed(), (ctrl.isDisposed() ? false : getTabFolder().isVisible()), garbageState, this); } /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. + * Accept the provided visitor. + * Call the corresponding accept method in the visitor. * * @param visitor * @return @@ -1068,8 +1031,10 @@ public class TabFolderPart extends AbstractTabFolderPart { return true; } + /** - * Collection of tabpart. Add miscelenaous methods. + * Collection of tabpart. + * Add miscelenaous methods. * * @author dumoulin * @@ -1088,10 +1053,10 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Returns the index of the first occurrence of the specified element in - * this list, or -1 if this list does not contain the element. More - * formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) , or -1 if - * there is no such index. + * Returns the index of the first occurrence of the specified element + * in this list, or -1 if this list does not contain the element. + * More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), + * or -1 if there is no such index. */ public int indexOfModel(Object o) { if(o == null) { @@ -1106,6 +1071,7 @@ public class TabFolderPart extends AbstractTabFolderPart { return -1; } + /** * Get the TabPart by its model. * @@ -1129,9 +1095,10 @@ public class TabFolderPart extends AbstractTabFolderPart { } /** - * Track the mouse for flying over the tabs and show tooltip. Show the - * tooltip when the mouse stop over a tab. Disable the tooltip if mouse is - * clicked. Reenable the tooltip when exiting the tab. + * Track the mouse for flying over the tabs and show tooltip. + * Show the tooltip when the mouse stop over a tab. + * Disable the tooltip if mouse is clicked. + * Reenable the tooltip when exiting the tab. * * @author dumoulin * @@ -1152,32 +1119,33 @@ public class TabFolderPart extends AbstractTabFolderPart { private int count = 0; public void mouseEnter(MouseEvent e) { - // System.out.println("MouseEnter()" + count++); + // System.out.println("MouseEnter()" + count++); } public void mouseExit(MouseEvent e) { - // System.out.println("MouseExit()" + count++); + // System.out.println("MouseExit()" + count++); toolTipManager.closeToolTip(); } public void mouseHover(MouseEvent e) { CTabFolder folder = getTabFolder(); - // Point pt = folder.toDisplay(e.x, e.y); + // Point pt = folder.toDisplay(e.x, e.y); Point pt = new Point(e.x, e.y); CTabItem item = folder.getItem(pt); int index = pTabFolder.getItemIndex(pt); - if(index == -1) { + if(index == -1) + { toolTipManager.closeToolTip(); return; } PagePart part = currentTabItems.get(index).getChildPart(); - // System.out.println("MouseHover(" + e.widget - // + ", part=" + part.getPartTitle() - // + ", item=" + item - // + ") - " + count++); - // TODO move it away +// System.out.println("MouseHover(" + e.widget +// + ", part=" + part.getPageTitle() +// + ", item=" + item +// + ") - " + count++); + // TODO move it away //toolTipManager.showToolTip(item.getBounds(), part.getControl(), pt); toolTipManager.showToolTip(part, item.getBounds(), pt); } @@ -1186,7 +1154,8 @@ public class TabFolderPart extends AbstractTabFolderPart { }; /** - * Listener on mouse clicked. Used to disable the current tooltip. + * Listener on mouse clicked. + * Used to disable the current tooltip. */ private Listener mouseClickedListener = new Listener() { @@ -1195,7 +1164,7 @@ public class TabFolderPart extends AbstractTabFolderPart { public void handleEvent(Event event) { switch(event.type) { case SWT.MouseUp: - // System.out.println("MouseUp()" + count++); +// System.out.println("MouseUp()" + count++); toolTipManager.disableToolTip(); break; } @@ -1203,7 +1172,8 @@ public class TabFolderPart extends AbstractTabFolderPart { }; /** - * Build a tracker for the specified control. Constructor. + * Build a tracker for the specified control. + * Constructor. * * @param control */ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java index 89dc1543ff1..580a6b4d085 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java @@ -22,9 +22,9 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Control; /** - * A controller associated to a tabitem in a tabfolder. This controller contains - * a reference to a PagePart. This class is used exclusively by the - * TabFolderPart. It should be not used from elsewhere. + * A controller associated to a tabitem in a tabfolder. This controller contains a reference to + * a PagePart. + * This class is used exclusively by the TabFolderPart. It should be not used from elsewhere. * * @author dumoulin * @@ -34,11 +34,10 @@ public class TabItemPart { /** * The associated model TODO : change the type */ - // protected Object model; + // protected Object model; /** - * The child associated to this tabitem. The child is rendered by the - * tabitem. + * The child associated to this tabitem. The child is rendered by the tabitem. */ protected PagePart childPart; @@ -49,8 +48,8 @@ public class TabItemPart { protected TabFolderPart parent; /** - * The SWT item associated to this part. This item contains the control of - * the associated editor. + * The SWT item associated to this part. This item contains the control of the + * associated editor. */ protected CTabItem control; @@ -58,7 +57,8 @@ public class TabItemPart { protected GarbageState garbageState; /** - * Constructor. Create a TabItem for the provided modelPart. + * Constructor. + * Create a TabItem for the provided modelPart. * * @param tabFolderPart * @param modelPart @@ -96,8 +96,7 @@ public class TabItemPart { } /** - * Reset this TabItem to use the new part. Reparent the new part and orphan - * the old part. + * Reset this TabItem to use the new part. Reparent the new part and orphan the old part. * * @param modelPart */ @@ -132,8 +131,10 @@ public class TabItemPart { } /** - * Remove the TabPart. Dispose the associated SWT CTabItem. (TODO Remove - * from the parent list.) Orphan the associated ITilePart + * Remove the TabPart. + * Dispose the associated SWT CTabItem. + * (TODO Remove from the parent list.) + * Orphan the associated ITilePart * * @see * @return the parent @@ -186,8 +187,8 @@ public class TabItemPart { } /** - * Dispose the associated control. Only dispose this tabitem, not the - * childpart. + * Dispose the associated control. + * Only dispose this tabitem, not the childpart. */ public void dispose() { Control itemControl = control.getControl(); @@ -232,23 +233,23 @@ public class TabItemPart { } /** - * Locates the part that intersects the given point and that have the - * expected type + * Locates the part that intersects the given point and that have the expected type * * @param position * @return */ public AbstractPart findPartAt(Point position, Class expectedTileType) { - // if(expectedTileType == this.getClass()) - // return this; + // if(expectedTileType == this.getClass()) + // return this; return childPart.findPartAt(position, expectedTileType); } + /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. + * Accept the provided visitor. + * Call the corresponding accept method in the visitor. * * @param visitor * @return @@ -276,4 +277,5 @@ public class TabItemPart { return rawModel.equals(getChildPart().getRawModel()); } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java index 293021bd59a..4951e15e8de 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java @@ -18,9 +18,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; /** - * Copy of org.eclipse.ui.part.MultiPageEditorPart. Change if to be suitable has - * a sash leaf. A multi-page editor is an editor with multiple pages, each of - * which may contain an editor or an arbitrary SWT control. + * Copy of org.eclipse.ui.part.MultiPageEditorPart. Change if to be suitable has a sash leaf. A multi-page editor is an editor with multiple pages, + * each of which may contain an editor or an arbitrary + * SWT control. *

          * This class is intented to separate folder stuff into 2 classes. Subclasses must implement the following methods: *

            @@ -42,8 +42,7 @@ import org.eclipse.swt.widgets.Control; public abstract class AbstractTabFolderPart extends AbstractPanelPart { /** - * Subclasses that override {@link #createPageContainer(Composite)} can use - * this constant to get a site for the container that can be active while + * Subclasses that override {@link #createPageContainer(Composite)} can use this constant to get a site for the container that can be active while * the current page is deactivated. * * @since 3.4 @@ -53,20 +52,18 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { */ protected static final int PAGE_CONTAINER_SITE = 65535; - // /** - // * Private tracing output. - // */ + // /** + // * Private tracing output. + // */ // private static final String TRACING_COMPONENT = "MPE"; //$NON-NLS-1$ - // /** - // * The active service locator. This value may be null if - // there is no selected page, or if the selected page is a control with no - // site. - // */ - // private INestable activeServiceLocator; + // /** + // * The active service locator. This value may be null if there is no selected page, or if the selected page is a control with no site. + // */ + // private INestable activeServiceLocator; // // - // private IServiceLocator pageContainerSite; + // private IServiceLocator pageContainerSite; /** * Creates an empty multi-page editor with no pages. @@ -76,8 +73,8 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { } /** - * The MultiPageEditor implementation of this IWorkbenchPart method creates the control for the multi-page - * editor by calling createContainer, then createPages. Subclasses should implement createPages rather than + * The MultiPageEditor implementation of this IWorkbenchPart method creates the control for the multi-page editor by + * calling createContainer, then createPages. Subclasses should implement createPages rather than * overriding this method. * * @param parent @@ -94,17 +91,16 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * * @return the active nested editor, or null if none */ - // public IEditorPart getActiveEditor() { - // int index = getActivePage(); - // if (index != -1) { - // return getEditor(index); - // } - // return null; - // } + // public IEditorPart getActiveEditor() { + // int index = getActivePage(); + // if (index != -1) { + // return getEditor(index); + // } + // return null; + // } /** - * Returns the index of the currently active page of this folder, or -1 if - * there is no active page. + * Returns the index of the currently active page of this folder, or -1 if there is no active page. *

            * Subclasses should not override this method *

            @@ -120,35 +116,31 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { } /** - * Returns the control for the given page index, or null if no - * control has been set for the page. The page index must be valid. + * Returns the control for the given page index, or null if no control has been set for the page. The page index must be valid. *

            * Subclasses should not override this method *

            * * @param pageIndex * the index of the page - * @return the control for the specified page, or null if none - * has been set + * @return the control for the specified page, or null if none has been set */ protected Control getControl(int pageIndex) { return getItem(pageIndex).getControl(); } /** - * Returns the editor for the given page index. The page index must be - * valid. + * Returns the editor for the given page index. The page index must be valid. * * @param pageIndex * the index of the page - * @return the editor for the specified page, or null if the - * specified page was not created with addPage(IEditorPart,IEditorInput) + * @return the editor for the specified page, or null if the specified page was not created with + * addPage(IEditorPart,IEditorInput) */ - // abstract protected IEditorPart getEditor(int pageIndex); + // abstract protected IEditorPart getEditor(int pageIndex); /** - * Returns the service locator for the given page index. This method can be - * used to create service locators for pages that are just controls. The + * Returns the service locator for the given page index. This method can be used to create service locators for pages that are just controls. The * page index must be valid. *

            * This will return the editor site service locator for an editor, and create one for a page that is just a control. @@ -156,20 +148,20 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * * @param pageIndex * the index of the page - * @return the editor for the specified page, or null if the - * specified page was not created with addPage(IEditorPart,IEditorInput) + * @return the editor for the specified page, or null if the specified page was not created with + * addPage(IEditorPart,IEditorInput) * @since 3.4 */ - // protected final IServiceLocator getPageSite(int pageIndex) { - // if (pageIndex == PAGE_CONTAINER_SITE) { - // return getPageContainerSite(); - // } + // protected final IServiceLocator getPageSite(int pageIndex) { + // if (pageIndex == PAGE_CONTAINER_SITE) { + // return getPageContainerSite(); + // } // - // /** - // * Return the site associated to the editor. - // */ - // return getEditor(pageIndex).getSite(); - // } + // /** + // * Return the site associated to the editor. + // */ + // return getEditor(pageIndex).getSite(); + // } /** * @return A site that can be used with a header. @@ -178,27 +170,24 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * @see #PAGE_CONTAINER_SITE * @see #getPageSite(int) */ - // private IServiceLocator getPageContainerSite() { - // if (pageContainerSite == null) { - // IServiceLocatorCreator slc = (IServiceLocatorCreator) - // getSite().getService(IServiceLocatorCreator.class); - // pageContainerSite = slc.createServiceLocator(getSite(), null, new - // IDisposable() { + // private IServiceLocator getPageContainerSite() { + // if (pageContainerSite == null) { + // IServiceLocatorCreator slc = (IServiceLocatorCreator) getSite().getService(IServiceLocatorCreator.class); + // pageContainerSite = slc.createServiceLocator(getSite(), null, new IDisposable() { // - // public void dispose() { - // final Control control = ((PartSite) getSite()).getPane().getControl(); - // if (control != null && !control.isDisposed()) { - // ((PartSite) getSite()).getPane().doHide(); - // } - // } - // }); - // } - // return pageContainerSite; - // } + // public void dispose() { + // final Control control = ((PartSite) getSite()).getPane().getControl(); + // if (control != null && !control.isDisposed()) { + // ((PartSite) getSite()).getPane().doHide(); + // } + // } + // }); + // } + // return pageContainerSite; + // } /** - * Returns the tab item for the given page index (page index is 0-based). - * The page index must be valid. + * Returns the tab item for the given page index (page index is 0-based). The page index must be valid. * * @param pageIndex * the index of the page @@ -230,8 +219,8 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { protected abstract CTabFolder getTabFolder(); /** - * Notifies this multi-page editor that the page with the given id has been - * activated. This method is called when the user selects a different tab. + * Notifies this multi-page editor that the page with the given id has been activated. This method is called when the user selects a different + * tab. *

            * The MultiPageEditorPart implementation of this method sets focus to the new page, and notifies the action bar contributor (if * there is one). This checks whether the action bar contributor is an instance of MultiPageEditorActionBarContributor, and, if so, @@ -245,57 +234,48 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * the index of the activated page */ protected void pageChange(int newPageIndex) { - // System.out.println(this.getClass().getSimpleName() + "pageChange()"); - // deactivateSite(false, false); + // System.out.println(this.getClass().getSimpleName() + "pageChange()"); + // deactivateSite(false, false); // - // IPartService partService = (IPartService) - // getSite().getService(IPartService.class); - // if (partService.getActivePart() == this) { - // setFocus(newPageIndex); - // } + // IPartService partService = (IPartService) getSite().getService(IPartService.class); + // if (partService.getActivePart() == this) { + // setFocus(newPageIndex); + // } // - // IEditorPart activeEditor = getEditor(newPageIndex); + // IEditorPart activeEditor = getEditor(newPageIndex); // - // IEditorActionBarContributor contributor = - // getEditorSite().getActionBarContributor(); - // if (contributor != null && contributor instanceof - // MultiPageEditorActionBarContributor) { - // ((MultiPageEditorActionBarContributor) - // contributor).setActivePage(activeEditor); - // } + // IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); + // if (contributor != null && contributor instanceof MultiPageEditorActionBarContributor) { + // ((MultiPageEditorActionBarContributor) contributor).setActivePage(activeEditor); + // } // - // if (activeEditor != null) { - // ISelectionProvider selectionProvider = - // activeEditor.getSite().getSelectionProvider(); - // if (selectionProvider != null) { - // ISelectionProvider outerProvider = getSite().getSelectionProvider(); - // if (outerProvider instanceof MultiPageSelectionProvider) { - // SelectionChangedEvent event = new - // SelectionChangedEvent(selectionProvider, - // selectionProvider.getSelection()); + // if (activeEditor != null) { + // ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); + // if (selectionProvider != null) { + // ISelectionProvider outerProvider = getSite().getSelectionProvider(); + // if (outerProvider instanceof MultiPageSelectionProvider) { + // SelectionChangedEvent event = new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()); // - // MultiPageSelectionProvider provider = (MultiPageSelectionProvider) - // outerProvider; - // provider.fireSelectionChanged(event); - // provider.firePostSelectionChanged(event); - // } else { - // if (Policy.DEBUG_MPE) { + // MultiPageSelectionProvider provider = (MultiPageSelectionProvider) outerProvider; + // provider.fireSelectionChanged(event); + // provider.firePostSelectionChanged(event); + // } else { + // if (Policy.DEBUG_MPE) { // Tracing.printTrace(TRACING_COMPONENT, "MultiPageEditorPart " + getTitle() //$NON-NLS-1$ // + " did not propogate selection for " //$NON-NLS-1$ - // + activeEditor.getTitle()); - // } - // } - // } - // } + // + activeEditor.getTitle()); + // } + // } + // } + // } // - // activateSite(); + // activateSite(); } /** - * This method can be used by implementors of {@link AbstractTabFolderPart#createPageContainer(Composite)} to - * deactivate the active inner editor services while their header has focus. - * A deactivateSite() must have a matching call to activateSite() when - * appropriate. + * This method can be used by implementors of {@link AbstractTabFolderPart#createPageContainer(Composite)} to deactivate the active inner editor + * services while their header has focus. A + * deactivateSite() must have a matching call to activateSite() when appropriate. *

            * An new inner editor will have its site activated on a {@link AbstractTabFolderPart#pageChange(int)}. *

            @@ -313,40 +293,38 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * @see #getPageSite(int) * @see #PAGE_CONTAINER_SITE */ - // protected final void deactivateSite(boolean immediate, boolean - // containerSiteActive) { - // // Deactivate the nested services from the last active service locator. - // if (activeServiceLocator != null) { - // activeServiceLocator.deactivate(); - // activeServiceLocator = null; - // } + // protected final void deactivateSite(boolean immediate, boolean containerSiteActive) { + // // Deactivate the nested services from the last active service locator. + // if (activeServiceLocator != null) { + // activeServiceLocator.deactivate(); + // activeServiceLocator = null; + // } // - // final int pageIndex = getActivePage(); - // final IKeyBindingService service = getSite().getKeyBindingService(); - // if (pageIndex < 0 || pageIndex >= getPageCount() || immediate) { - // // There is no selected page, so deactivate the active service. - // if (service instanceof INestableKeyBindingService) { - // final INestableKeyBindingService nestableService = - // (INestableKeyBindingService) service; - // nestableService.activateKeyBindingService(null); - // } else { - // WorkbenchPlugin + // final int pageIndex = getActivePage(); + // final IKeyBindingService service = getSite().getKeyBindingService(); + // if (pageIndex < 0 || pageIndex >= getPageCount() || immediate) { + // // There is no selected page, so deactivate the active service. + // if (service instanceof INestableKeyBindingService) { + // final INestableKeyBindingService nestableService = (INestableKeyBindingService) service; + // nestableService.activateKeyBindingService(null); + // } else { + // WorkbenchPlugin // .log("MultiPageEditorPart.deactivateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // } + // } + // } // - // if (containerSiteActive) { - // IServiceLocator containerSite = getPageContainerSite(); - // if (containerSite instanceof INestable) { - // activeServiceLocator = (INestable) containerSite; - // activeServiceLocator.activate(); - // } - // } - // } + // if (containerSiteActive) { + // IServiceLocator containerSite = getPageContainerSite(); + // if (containerSite instanceof INestable) { + // activeServiceLocator = (INestable) containerSite; + // activeServiceLocator.activate(); + // } + // } + // } /** - * This method can be used by implementors of {@link #createPageContainer(Composite)} to activate the active inner - * editor services when their header loses focus. + * This method can be used by implementors of {@link #createPageContainer(Composite)} to activate the active inner editor services when their + * header loses focus. *

            * An new inner editor will have its site activated on a {@link #pageChange(int)}. *

            @@ -359,76 +337,74 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * @see #createPageContainer(Composite) * @see #getPageSite(int) */ - // protected final void activateSite() { - // if (activeServiceLocator != null) { - // activeServiceLocator.deactivate(); - // activeServiceLocator = null; - // } + // protected final void activateSite() { + // if (activeServiceLocator != null) { + // activeServiceLocator.deactivate(); + // activeServiceLocator = null; + // } // - // final IKeyBindingService service = getSite().getKeyBindingService(); - // final int pageIndex = getActivePage(); - // final IEditorPart editor = getEditor(pageIndex); + // final IKeyBindingService service = getSite().getKeyBindingService(); + // final int pageIndex = getActivePage(); + // final IEditorPart editor = getEditor(pageIndex); // - // if (editor != null) { - // // active the service for this inner editor - // if (service instanceof INestableKeyBindingService) { - // final INestableKeyBindingService nestableService = - // (INestableKeyBindingService) service; - // nestableService.activateKeyBindingService(editor.getEditorSite()); + // if (editor != null) { + // // active the service for this inner editor + // if (service instanceof INestableKeyBindingService) { + // final INestableKeyBindingService nestableService = (INestableKeyBindingService) service; + // nestableService.activateKeyBindingService(editor.getEditorSite()); // - // } else { - // WorkbenchPlugin + // } else { + // WorkbenchPlugin // .log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // // Activate the services for the new service locator. - // final IServiceLocator serviceLocator = editor.getEditorSite(); - // if (serviceLocator instanceof INestable) { - // activeServiceLocator = (INestable) serviceLocator; - // activeServiceLocator.activate(); - // } + // } + // // Activate the services for the new service locator. + // final IServiceLocator serviceLocator = editor.getEditorSite(); + // if (serviceLocator instanceof INestable) { + // activeServiceLocator = (INestable) serviceLocator; + // activeServiceLocator.activate(); + // } // - // } else { - // Item item = getItem(pageIndex); + // } else { + // Item item = getItem(pageIndex); // - // // There is no selected editor, so deactivate the active service. - // if (service instanceof INestableKeyBindingService) { - // final INestableKeyBindingService nestableService = - // (INestableKeyBindingService) service; - // nestableService.activateKeyBindingService(null); - // } else { - // WorkbenchPlugin + // // There is no selected editor, so deactivate the active service. + // if (service instanceof INestableKeyBindingService) { + // final INestableKeyBindingService nestableService = (INestableKeyBindingService) service; + // nestableService.activateKeyBindingService(null); + // } else { + // WorkbenchPlugin // .log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - // } + // } // - // if (item.getData() instanceof INestable) { - // activeServiceLocator = (INestable) item.getData(); - // activeServiceLocator.activate(); - // } - // } - // } + // if (item.getData() instanceof INestable) { + // activeServiceLocator = (INestable) item.getData(); + // activeServiceLocator.activate(); + // } + // } + // } - // /** - // * Disposes the given part and its site. - // * - // * @param part - // * The part to dispose; must not be null. - // */ - // private void disposePart(final IWorkbenchPart part) { - // SafeRunner.run(new ISafeRunnable() { + // /** + // * Disposes the given part and its site. + // * + // * @param part + // * The part to dispose; must not be null. + // */ + // private void disposePart(final IWorkbenchPart part) { + // SafeRunner.run(new ISafeRunnable() { // - // public void run() { - // IWorkbenchPartSite partSite = part.getSite(); - // part.dispose(); - // if (partSite instanceof MultiPageEditorSite) { - // ((MultiPageEditorSite) partSite).dispose(); - // } - // } + // public void run() { + // IWorkbenchPartSite partSite = part.getSite(); + // part.dispose(); + // if (partSite instanceof MultiPageEditorSite) { + // ((MultiPageEditorSite) partSite).dispose(); + // } + // } // - // public void handleException(Throwable e) { - // // Exception has already being logged by Core. Do nothing. - // } - // }); - // } + // public void handleException(Throwable e) { + // // Exception has already being logged by Core. Do nothing. + // } + // }); + // } /** * Sets the currently active page for this folder. @@ -437,7 +413,7 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * the index of the page to be activated; the index must be valid */ public void setActivePage(int pageIndex) { - // Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount()); + // Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount()); if(!isValidPageIndex(pageIndex)) return; @@ -446,8 +422,9 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { } /** - * Return true if the specified index is valid. The index should be between - * 0 and pageCount. If there is no page, return false. + * Return true if the specified index is valid. + * The index should be between 0 and pageCount. + * If there is no page, return false. * * @param pageIndex * @return @@ -463,39 +440,40 @@ public abstract class AbstractTabFolderPart extends AbstractPanelPart { * @param pageIndex * the index of the page * @param control - * the control for the specified page, or null to - * clear the control + * the control for the specified page, or null to clear the control */ protected void setControl(int pageIndex, Control control) { getItem(pageIndex).setControl(control); } + /* *************************************** */ /* Added method. */ /* *************************************** */ - // /** - // * Title of this TilePart ? Needed by a trace message. - // */ - // protected String getTitle() { - // return getClass().toString(); - // } + // /** + // * Title of this TilePart ? Needed by a trace message. + // */ + // protected String getTitle() { + // return getClass().toString(); + // } // - // /** - // * - // */ - // protected IWorkbenchPartSite getSite() { - // return getEditorSite(); - // } + // /** + // * + // */ + // protected IWorkbenchPartSite getSite() { + // return getEditorSite(); + // } // - // /** - // * - // */ - // abstract protected void firePropertyChange(int propertyId); + // /** + // * + // */ + // abstract protected void firePropertyChange(int propertyId); // - // /** - // * - // */ - // abstract protected IEditorSite getEditorSite(); + // /** + // * + // */ + // abstract protected IEditorSite getEditorSite(); + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java index 8030ae5cea4..a905b736a53 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java @@ -24,9 +24,9 @@ import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiPageEditorPart; import org.eclipse.ui.IEditorPart; /** - * Manages the current selection in a multi-page editor by tracking the active - * nested editor within the multi-page editor. When the selection changes, - * notifications are sent to all registered listeners. + * Manages the current selection in a multi-page editor by tracking the active nested editor within the multi-page editor. When the selection changes, + * notifications are sent to all registered + * listeners. *

            * This class may be instantiated; it is not intended to be subclassed. The base implementation of MultiPageEditor.init creates an * instance of this class. @@ -70,8 +70,7 @@ public class MultiPageSelectionProvider implements IPostSelectionProvider { } /** - * Adds a listener for post selection changes in this multi page selection - * provider. + * Adds a listener for post selection changes in this multi page selection provider. * * @param listener * a selection changed listener @@ -82,8 +81,7 @@ public class MultiPageSelectionProvider implements IPostSelectionProvider { } /** - * Notifies all registered selection changed listeners that the editor's - * selection has changed. Only listeners registered at the time this method + * Notifies all registered selection changed listeners that the editor's selection has changed. Only listeners registered at the time this method * is called are notified. * * @param event @@ -95,8 +93,7 @@ public class MultiPageSelectionProvider implements IPostSelectionProvider { } /** - * Notifies all post selection changed listeners that the editor's selection - * has changed. + * Notifies all post selection changed listeners that the editor's selection has changed. * * @param event * the event to propogate. @@ -119,14 +116,14 @@ public class MultiPageSelectionProvider implements IPostSelectionProvider { } } - // /** - // * Returns the multi-page editor. - // * - // * @return the multi-page editor. - // */ - // private IMultiPageEditorPart getMultiPageEditor() { - // return multiPageEditor; - // } + // /** + // * Returns the multi-page editor. + // * + // * @return the multi-page editor. + // */ + // private IMultiPageEditorPart getMultiPageEditor() { + // return multiPageEditor; + // } /* * (non-Javadoc) Method declared on ISelectionProvider. @@ -150,8 +147,7 @@ public class MultiPageSelectionProvider implements IPostSelectionProvider { } /** - * Removes a listener for post selection changes in this multi page - * selection provider. + * Removes a listener for post selection changes in this multi page selection provider. * * @param listener * a selection changed listener diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java index ad06108309f..45bdd224c59 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java @@ -34,19 +34,19 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.MultiPageEditorPart; /** - * A MultiPageEditor implementation accepting IMultiSashContentProvider as - * content provider. This implementation extends the regular eclipse - * MultiPageEditorPart. The refresh() method allows to refresh the tabs. + * A MultiPageEditor implementation accepting IMultiSashContentProvider as content provider. + * This implementation extends the regular eclipse MultiPageEditorPart. + * The refresh() method allows to refresh the tabs. * - * The implementation do not listen on model change. This can be done by - * subclasses. To add a new tab, one should add it as a model in the - * ContentProvider. The addPage() methods should not be used for this purpose. + * The implementation do not listen on model change. This can be done by subclasses. + * To add a new tab, one should add it as a model in the ContentProvider. The addPage() + * methods should not be used for this purpose. * - * This implementation is intended for debug and testing purpose : it can be - * used in place of the AbstractMultiPageSashEditor. It takes the same arguments - * and ContentProvider, but it only allows one folder and don't deal with - * multisashes. Also, the implementation use the regular Eclipse EditorSite - * management. This allows to check for problems from this site management. + * This implementation is intended for debug and testing purpose : it can be used in place + * of the AbstractMultiPageSashEditor. It takes the same arguments and ContentProvider, but + * it only allows one folder and don't deal with multisashes. + * Also, the implementation use the regular Eclipse EditorSite management. This allows to check for problems from this + * site management. * * @author dumoulin */ @@ -74,8 +74,9 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { } /** - * This method is called at the end of createPartControl(). Just intercept - * the call in order to call activate(). Create the part controls. {@inheritDoc} + * This method is called at the end of createPartControl(). + * Just intercept the call in order to call activate(). + * Create the part controls. {@inheritDoc} */ @Override protected void initializePageSwitching() { @@ -85,17 +86,18 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { } /** - * Method to activate the editor. Called immediately after - * createPartControl() is complete. To be implemented by subclasses. Default - * implementation do nothing. + * Method to activate the editor. + * Called immediately after createPartControl() is complete. + * To be implemented by subclasses. Default implementation do nothing. */ protected void activate() { } /** - * Method to deactivate the editor. Called when dispose() is called. To be - * implemented by subclasses. Default implementation do nothing. + * Method to deactivate the editor. + * Called when dispose() is called. + * To be implemented by subclasses. Default implementation do nothing. */ protected void deactivate() { @@ -111,7 +113,7 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { public void dispose() { deactivate(); super.dispose(); - // sashContainer.dispose(); + // sashContainer.dispose(); } @Override @@ -136,6 +138,8 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { return pageProvider; } + + /** * @param pageProvider * the pageProvider to set @@ -175,7 +179,11 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { setPageImage(index, image); return index; } catch (PartInitException e) { - ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); + ErrorDialog.openError( + getSite().getShell(), + "Error creating nested text editor", + null, + e.getStatus()); return -1; } @@ -188,31 +196,29 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { // get the page descriptions pageProvider = getContentProvider(); // Get the current tabFolder - // + // tabFolderModel = lookupFolder(); refreshTabs(); - // // iterate over pages to be show - // for( Object rawPageModel : tabFolderModel.getChildren() ) - // { - // // Get the model interface - // ITabItemModel tabItem = tabFolderModel.createChildSashModel( - // rawPageModel); - // if(tabItem instanceof IEditorModel ) - // { - // addPage((IEditorModel)tabItem ); - // } - // else if(tabItem instanceof IComponentModel ) - // { - // addPage((IComponentModel)tabItem ); - // } - // else - // { - // System.err.println("Can't create page for model '" + tabItem + - // "'. Skipp it."); - // } - // } + // // iterate over pages to be show + // for( Object rawPageModel : tabFolderModel.getChildren() ) + // { + // // Get the model interface + // ITabItemModel tabItem = tabFolderModel.createChildSashModel( rawPageModel); + // if(tabItem instanceof IEditorModel ) + // { + // addPage((IEditorModel)tabItem ); + // } + // else if(tabItem instanceof IComponentModel ) + // { + // addPage((IComponentModel)tabItem ); + // } + // else + // { + // System.err.println("Can't create page for model '" + tabItem + "'. Skipp it."); + // } + // } } /** @@ -231,8 +237,8 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { } /** - * Recursively search in sash models for a FolderModel. Return the first - * encountered folder. + * Recursively search in sash models for a FolderModel. + * Return the first encountered folder. * * @param panelModel * @return @@ -256,22 +262,21 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { } /** - * Create the provider. Subclass must implements this method. It should - * return the provider used by the editor. + * Create the provider. + * Subclass must implements this method. It should return the provider used by the editor. * */ abstract protected ISashWindowsContentProvider createPageProvider(); /** - * Refresh the tabs order. This method should be called after the model list - * is modified. + * Refresh the tabs order. + * This method should be called after the model list is modified. */ protected void refreshTabs() { // get list of diagrams to be displayed List newModels = tabFolderModel.getChildren(); - // Check if each model has an open pageEditor. If not, create the - // editor. + // Check if each model has an open pageEditor. If not, create the editor. Iterator newIter = newModels.iterator(); while(newIter.hasNext()) { Object model = newIter.next(); @@ -283,7 +288,7 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { } } - // If open editor count is the same has models count, + // If open editor count is the same has models count, // all models have an editor. So, end the refresh process. if(newModels.size() == getPageCount()) return; @@ -323,6 +328,7 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { return false; } + /* * (non-Javadoc) * @@ -347,8 +353,8 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { } /** - * Add a new editor at the end of existing editors. First, create the - * editor, then add it to the tabs. + * Add a new editor at the end of existing editors. + * First, create the editor, then add it to the tabs. * * @param contentProvider * the diagram (model) to be displayed in the editor @@ -373,9 +379,10 @@ public abstract class MultiPageEditor extends MultiPageEditorPart { // Add the model in the list of current tabs. currentTabs.add(tabItem); - // set active page + // set active page setActivePage(editorIndex); } + } -- cgit v1.2.3