[478139] Dead lock on refresh on ActivityExplorer
Bug: 478139
Change-Id: I2e2c258263d7cb3712b19706fa6205a2e7a5192d
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
index 383d449..9375792 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
@@ -18,8 +18,6 @@
import org.eclipse.amalgam.explorer.activity.ui.ActivityExplorerActivator;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.input.ActivityExplorerEditorInput;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.CommonActivityExplorerPage;
-import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.ActivityExplorerPage;
-import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.BasicSessionActivityExplorerPage;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.DocumentationActivityExplorerPage;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.OverviewActivityExplorerPage;
import org.eclipse.amalgam.explorer.activity.ui.api.manager.ActivityExplorerManager;
@@ -33,7 +31,6 @@
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.sirius.business.api.session.Session;
-import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.business.api.session.SessionStatus;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
@@ -54,485 +51,453 @@
/**
* Base class to implement Activity Explorer.
- *
*/
-public class ActivityExplorerEditor extends SharedHeaderFormEditor implements ITabbedPropertySheetPageContributor,
- IPropertyChangeListener {
- /**
- * Logger.
- */
- // private static final Logger __logger =
- // ReportManagerRegistry.getInstance().subscribe(IReportManagerDefaultComponents.UI);
- /**
- * Editor ID.
- */
- public static final String ID = "org.eclipse.amalgam.explorer.activity.ui.editor.activityExplorerEditor"; //$NON-NLS-1$
- /**
- * Part listener to detect editor activation.
- */
- private IPartListener _partListener;
- /**
- * Property Sheet page.
- */
- private TabbedPropertySheetPage _propertySheetPage;
+public class ActivityExplorerEditor extends SharedHeaderFormEditor implements ITabbedPropertySheetPageContributor, IPropertyChangeListener {
+ /**
+ * Logger.
+ */
+ // private static final Logger __logger =
+ // ReportManagerRegistry.getInstance().subscribe(IReportManagerDefaultComponents.UI);
- public ActivityExplorerEditor() {
- ActivityExplorerManager.INSTANCE.setEditor(this);
- }
+ /**
+ * Editor ID.
+ */
+ public static final String ID = "org.eclipse.amalgam.explorer.activity.ui.editor.activityExplorerEditor"; //$NON-NLS-1$
+ /**
+ * Part listener to detect editor activation.
+ */
+ private IPartListener _partListener;
+ /**
+ * Property Sheet page.
+ */
+ private TabbedPropertySheetPage _propertySheetPage;
- /**
- * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
- */
- @Override
- protected void addPages() {
- try {
+ public ActivityExplorerEditor() {
+ ActivityExplorerManager.INSTANCE.setEditor(this);
+ }
- // OVERVIEW IS FIRST PAGE (Default or contributed)
- OverviewActivityExplorerPage overViewPage = getOrCreateOverviewActivityExplorerPage();
- addPage(overViewPage);
+ /**
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ @Override
+ protected void addPages() {
+ try {
- // set editor in the Activity Explorer Manager
- ActivityExplorerManager.INSTANCE.setEditor(this);
- // Add other Pages (plug-ins contribution)
- createContributedPages();
+ // OVERVIEW IS FIRST PAGE (Default or contributed)
+ OverviewActivityExplorerPage overViewPage = getOrCreateOverviewActivityExplorerPage();
+ addPage(overViewPage);
- } catch (PartInitException exception) {
- StringBuilder loggerMessage = new StringBuilder("ActivityExplorerEditor.addPages(..) _ "); //$NON-NLS-1$
- loggerMessage.append(exception.getMessage());
- }
- // Add a control listener to force reflow
- getContainer().addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent cevent) {
- // Do nothing.
+ // set editor in the Activity Explorer Manager
+ ActivityExplorerManager.INSTANCE.setEditor(this);
+ // Add other Pages (plug-ins contribution)
+ createContributedPages();
- }
+ } catch (PartInitException exception) {
+ StringBuilder loggerMessage = new StringBuilder("ActivityExplorerEditor.addPages(..) _ "); //$NON-NLS-1$
+ loggerMessage.append(exception.getMessage());
+ }
+ // Add a control listener to force reflow
+ getContainer().addControlListener(new ControlListener() {
+ public void controlMoved(ControlEvent cevent) {
+ // Do nothing.
- public void controlResized(ControlEvent cevent) {
- IFormPage activePageInstance = ActivityExplorerEditor.this.getActivePageInstance();
- IManagedForm managedForm = activePageInstance.getManagedForm();
- managedForm.reflow(true);
- }
- });
- // Refresh dirty state when the part is activated : open time for
- // instance.
- getHeaderForm().dirtyStateChanged();
- ActivityExplorerActivator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+ }
- // because the pages is update later
- pages.remove(null);
+ public void controlResized(ControlEvent cevent) {
+ IFormPage activePageInstance = ActivityExplorerEditor.this.getActivePageInstance();
+ IManagedForm managedForm = activePageInstance.getManagedForm();
+ managedForm.reflow(true);
+ }
+ });
+ // Refresh dirty state when the part is activated : open time for
+ // instance.
+ getHeaderForm().dirtyStateChanged();
+ ActivityExplorerActivator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
+ // because the pages is update later
+ pages.remove(null);
- /**
- * Returns all pages in the Editor
- *
- * @return Vector<AbstractActivityExplorerPage>
- */
- @SuppressWarnings("unchecked")
- public Vector<CommonActivityExplorerPage> getPages() {
- return pages;
- }
+ }
- /**
- * Remove all Pages contained in this editor.
- */
- public void removeAllPages() {
- int count = super.getPageCount();
- for (int i = 0; i < count; i++) {
- this.removePage(0);
- }
- }
+ /**
+ * Returns all pages in the Editor
+ * @return Vector<AbstractActivityExplorerPage>
+ */
+ @SuppressWarnings("unchecked")
+ public Vector<CommonActivityExplorerPage> getPages() {
+ return pages;
+ }
- /**
- * Create and Insert Contributed pages in the editor
- */
- private void createContributedPages() throws PartInitException {
- List<CommonActivityExplorerPage> temp = ActivityExplorerExtensionManager.getAllPages();
- Collections.sort(temp);
- for (CommonActivityExplorerPage page : temp) {
- if (page instanceof IVisibility && !(page.getPosition() == 0))
- if (page.isVisible()) {
- addNewPage(page);
+ /**
+ * Remove all Pages contained in this editor.
+ */
+ public void removeAllPages() {
+ int count = super.getPageCount();
+ for (int i = 0; i < count; i++) {
+ this.removePage(0);
+ }
+ }
- }
- }
- }
+ /**
+ * Create and Insert Contributed pages in the editor
+ */
+ private void createContributedPages() throws PartInitException {
+ List<CommonActivityExplorerPage> temp = ActivityExplorerExtensionManager.getAllPages();
+ Collections.sort(temp);
+ for (CommonActivityExplorerPage page : temp) {
+ if ((page instanceof IVisibility) && !(page.getPosition() == 0)) {
+ if (page.isVisible()) {
+ addNewPage(page);
- /**
- * Create a documentation page.
- *
- * @return a not <code>null</code> instance.
- */
- protected IFormPage createDocumentationPage() {
- return new DocumentationActivityExplorerPage(this);
- }
-
- /**
- * Get or create the main Overview page
- *
- * @return a not <code>null</code> instance.
- */
- protected OverviewActivityExplorerPage getOrCreateOverviewActivityExplorerPage() {
- List<CommonActivityExplorerPage> contributedPages = ActivityExplorerExtensionManager.getAllPages();
- Collections.sort(contributedPages);
- if(!contributedPages.isEmpty()){
- CommonActivityExplorerPage page = contributedPages.get(0);
- if(page instanceof OverviewActivityExplorerPage && page.getPosition() == 0){
- page.initialize(this);
- return (OverviewActivityExplorerPage)page;
+ }
}
}
- return new OverviewActivityExplorerPage(this);
- }
+ }
- /**
- * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
- */
- @Override
- public void dispose() {
- // Dispose the property sheet page.
- if (null != _propertySheetPage) {
- _propertySheetPage.dispose();
- _propertySheetPage = null;
- }
- // Unregister Sirius session listener.
- unregisterSession();
- // Remove part listener.
- if (null != _partListener) {
- getEditorSite().getPage().removePartListener(_partListener);
- _partListener = null;
- }
- super.dispose();
+ /**
+ * Create a documentation page.
+ * @return a not <code>null</code> instance.
+ */
+ protected IFormPage createDocumentationPage() {
+ return new DocumentationActivityExplorerPage(this);
+ }
- if (null != getEditorInput()) {
- getEditorInput().dispose();
- }
- }
+ /**
+ * Get or create the main Overview page
+ * @return a not <code>null</code> instance.
+ */
+ protected OverviewActivityExplorerPage getOrCreateOverviewActivityExplorerPage() {
+ List<CommonActivityExplorerPage> contributedPages = ActivityExplorerExtensionManager.getAllPages();
+ Collections.sort(contributedPages);
+ if (!contributedPages.isEmpty()) {
+ CommonActivityExplorerPage page = contributedPages.get(0);
+ if ((page instanceof OverviewActivityExplorerPage) && (page.getPosition() == 0)) {
+ page.initialize(this);
+ return (OverviewActivityExplorerPage) page;
+ }
+ }
+ return new OverviewActivityExplorerPage(this);
+ }
- /**
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void doSave(IProgressMonitor monitor) {
- if (isDirty()) {
- getEditorInput().getSession().save(new NullProgressMonitor());
- }
- }
+ /**
+ * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Dispose the property sheet page.
+ if (null != _propertySheetPage) {
+ _propertySheetPage.dispose();
+ _propertySheetPage = null;
+ }
+ // Unregister Sirius session listener.
+ unregisterSession();
+ // Remove part listener.
+ if (null != _partListener) {
+ getEditorSite().getPage().removePartListener(_partListener);
+ _partListener = null;
+ }
+ super.dispose();
- /**
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- @Override
- public void doSaveAs() {
- // Do nothing.
- }
+ if (null != getEditorInput()) {
+ getEditorInput().dispose();
+ }
+ }
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (IPropertySheetPage.class.equals(adapter)) {
- return getOrCreatePropertySheetPage();
- }
- return super.getAdapter(adapter);
- }
+ /**
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ if (isDirty()) {
+ getEditorInput().getSession().save(new NullProgressMonitor());
+ }
+ }
- public static final String PROPERTIES_CONTRIBUTOR = "org.eclipse.amalgam.explorer.activity.ui.editor.properties"; //$NON-NLS-1$
+ /**
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ // Do nothing.
+ }
- /**
- * {@inheritDoc}
- */
- public String getContributorId() {
- return getSite().getId();// PROPERTIES_CONTRIBUTOR;
- }
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (IPropertySheetPage.class.equals(adapter)) {
+ return getOrCreatePropertySheetPage();
+ }
+ return super.getAdapter(adapter);
+ }
- /**
- * @see org.eclipse.ui.part.EditorPart#getEditorInput()
- */
- @Override
- public ActivityExplorerEditorInput getEditorInput() {
- return (ActivityExplorerEditorInput) super.getEditorInput();
- }
+ public static final String PROPERTIES_CONTRIBUTOR = "org.eclipse.amalgam.explorer.activity.ui.editor.properties"; //$NON-NLS-1$
- /**
- * Get or create (first call) the property sheet page.
- */
- private IPropertySheetPage getOrCreatePropertySheetPage() {
- if ((null == _propertySheetPage)) {
- _propertySheetPage = new TabbedPropertySheetPage(this) {
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("synthetic-access")
- @Override
- public void dispose() {
- super.dispose();
- _propertySheetPage = null;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getContributorId() {
+ return getSite().getId();// PROPERTIES_CONTRIBUTOR;
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(IPageSite pageSite) {
- super.init(pageSite);
- pageSite.setSelectionProvider(ActivityExplorerEditor.this.getEditorSite().getSelectionProvider());
- }
- };
- }
- return _propertySheetPage;
- }
+ /**
+ * @see org.eclipse.ui.part.EditorPart#getEditorInput()
+ */
+ @Override
+ public ActivityExplorerEditorInput getEditorInput() {
+ return (ActivityExplorerEditorInput) super.getEditorInput();
+ }
- /**
- * @see org.eclipse.ui.part.WorkbenchPart#getPartName()
- */
- @Override
- public String getPartName() {
- return getEditorInput().getName() + Messages.ActivityExplorerEditor_Title_Suffix;
- }
+ /**
+ * Get or create (first call) the property sheet page.
+ */
+ private IPropertySheetPage getOrCreatePropertySheetPage() {
+ if ((null == _propertySheetPage)) {
+ _propertySheetPage = new TabbedPropertySheetPage(this) {
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void dispose() {
+ super.dispose();
+ _propertySheetPage = null;
+ }
- /**
- * Get property sheet page accessor.
- *
- * @return <code>null</code> if the property sheet view is not displayed.
- */
- public TabbedPropertySheetPage getPropertySheetPage() {
- return _propertySheetPage;
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ pageSite.setSelectionProvider(ActivityExplorerEditor.this.getEditorSite().getSelectionProvider());
+ }
+ };
+ }
+ return _propertySheetPage;
+ }
- /**
- * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- if (null == ((ActivityExplorerEditorInput) input).getRootSemanticElement()) {
- throw new PartInitException(new Status(IStatus.WARNING, ActivityExplorerActivator.ID,
- Messages.ActivityExplorerEditor_1));
- }
- super.init(site, input);
+ /**
+ * @see org.eclipse.ui.part.WorkbenchPart#getPartName()
+ */
+ @Override
+ public String getPartName() {
+ return getEditorInput().getName() + Messages.ActivityExplorerEditor_Title_Suffix;
+ }
- // PArt listener to detect when this editor is activated.
- _partListener = new IPartListener() {
- /**
- * {@inheritDoc}
- */
- public void partActivated(IWorkbenchPart part) {
- if (ActivityExplorerEditor.this == part) {
- IFormPage activePageInstance = ActivityExplorerEditor.this.getActivePageInstance();
- // Make sure action bars
+ /**
+ * Get property sheet page accessor.
+ * @return <code>null</code> if the property sheet view is not displayed.
+ */
+ public TabbedPropertySheetPage getPropertySheetPage() {
+ return _propertySheetPage;
+ }
- // send Fake Notification to SessionListener
- if (activePageInstance instanceof CommonActivityExplorerPage) {
+ /**
+ * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ if (null == ((ActivityExplorerEditorInput) input).getRootSemanticElement()) {
+ throw new PartInitException(new Status(IStatus.WARNING, ActivityExplorerActivator.ID, Messages.ActivityExplorerEditor_1));
+ }
+ super.init(site, input);
- Session session = getEditorInput().getSession();
- if (session != null)
- SessionManager.INSTANCE.notifyRepresentationCreated(session);
- }
+ // Part listener to detect when this editor is activated.
+ _partListener = new IPartListener() {
+ /**
+ * {@inheritDoc}
+ */
+ public void partActivated(IWorkbenchPart part) {
+ if (ActivityExplorerEditor.this == part) {
+ IFormPage activePageInstance = ActivityExplorerEditor.this.getActivePageInstance();
+ activePageInstance.setActive(true);
+ }
+ }
- if (activePageInstance instanceof ActivityExplorerPage)
- ((ActivityExplorerPage) activePageInstance).updateActionBars();
- }
- }
+ /**
+ * {@inheritDoc}
+ */
- /**
- * {@inheritDoc}
- */
+ public void partBroughtToTop(IWorkbenchPart part) {
+ // Do nothing.
+ }
- public void partBroughtToTop(IWorkbenchPart part) {
- // Do nothing.
- }
+ /**
+ * {@inheritDoc}
+ */
- /**
- * {@inheritDoc}
- */
+ public void partClosed(IWorkbenchPart part) {
+ // Do nothing.
+ }
- public void partClosed(IWorkbenchPart part) {
- // Do nothing.
- }
+ /**
+ * {@inheritDoc}
+ */
- /**
- * {@inheritDoc}
- */
+ public void partDeactivated(IWorkbenchPart part) {
+ // Do nothing.
+ }
- public void partDeactivated(IWorkbenchPart part) {
- // Do nothing.
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void partOpened(IWorkbenchPart part) {
+ // Do nothing.
+ }
+ };
+ getEditorSite().getPage().addPartListener(_partListener);
+ }
- /**
- * {@inheritDoc}
- */
- public void partOpened(IWorkbenchPart part) {
- // Do nothing.
- }
- };
- getEditorSite().getPage().addPartListener(_partListener);
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isDirty() {
+ final Session session = getEditorInput().getSession();
+ if (null != session) {
+ return SessionStatus.DIRTY.equals(session.getStatus());
+ }
+ return false;
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isDirty() {
- final Session session = getEditorInput().getSession();
- if (null != session) {
- return SessionStatus.DIRTY.equals(session.getStatus());
- }
- return false;
- }
+ /**
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ // Not applicable in this editor.
+ return false;
+ }
- /**
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- @Override
- public boolean isSaveAsAllowed() {
- // Not applicable in this editor.
- return false;
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isSaveOnCloseNeeded() {
+ // See with SBo, we don't want to save on close.
+ return false;
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSaveOnCloseNeeded() {
- // See with SBo, we don't want to save on close.
- return false;
- }
+ /**
+ * Unregister the session listener and set the session to <code>null</code>.
+ */
+ private void unregisterSession() {
+ ActivityExplorerEditorInput editorInput = getEditorInput();
+ if (null != editorInput) {
+ Session session = editorInput.getSession();
+ if (null != session) {
+ session = null;
+ }
+ }
+ }
- /**
- * Mark given page as dirty.
- *
- * @param page
- */
- @SuppressWarnings("unused")
- private void markArchitecturePageAsDirty(BasicSessionActivityExplorerPage page) {
- if (null != page) {
- page.markAsDirty();
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getTitleImage() {
+ ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
+ Image decoratedImage = decorator.decorateImage(super.getTitleImage(), getEditorInput().getSession());
- /**
- * Unregister the session listener and set the session to <code>null</code>.
- */
- private void unregisterSession() {
- ActivityExplorerEditorInput editorInput = getEditorInput();
- if (null != editorInput) {
- Session session = editorInput.getSession();
- if (null != session) {
- // Remove the session listener.
- // SessionManager.INSTANCE.removeSessionsListener(this);
- session = null;
- }
- }
- }
+ return decoratedImage;
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public Image getTitleImage() {
- ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
- Image decoratedImage = decorator.decorateImage(super.getTitleImage(), getEditorInput().getSession());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setTitleImage(Image titleImage) {
+ super.setTitleImage(titleImage);
+ }
- return decoratedImage;
- }
+ private int addNewPage(IFormPage page) {
+ int index = 0;
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setTitleImage(Image titleImage) {
- super.setTitleImage(titleImage);
- }
+ page.initialize(this);
- private int addNewPage(IFormPage page) {
- int index = 0;
+ try {
+ index = addPage(page);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ return index;
+ }
- page.initialize(this);
+ /**
+ * Get the previous page
+ * @param current
+ * @return the previous page or null
+ */
+ @SuppressWarnings("unchecked")
+ public IFormPage getPreviousPage(IFormPage current) {
+ IFormPage previousPage = null;
+ int i = pages.indexOf(current);
+ if (i > -1) {
+ ListIterator<CommonActivityExplorerPage> it = pages.listIterator(i);
+ if (it.hasPrevious()) {
+ previousPage = it.previous();
+ }
+ }
+ return previousPage;
+ }
- try {
- index = addPage(page);
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- return index;
- }
+ /**
+ * Get the next page
+ * @param current
+ * @return the next page or null
+ */
+ @SuppressWarnings("unchecked")
+ public IFormPage getNextPage(IFormPage current) {
+ IFormPage nextPage = null;
+ int i = pages.indexOf(current);
+ if (i > -1) {
+ ListIterator<CommonActivityExplorerPage> it = pages.listIterator(i + 1);
+ if (it.hasNext()) {
+ nextPage = it.next();
+ }
+ }
+ return nextPage;
+ }
- /**
- * Get the previous page
- *
- * @param current
- * @return the previous page or null
- */
- @SuppressWarnings("unchecked")
- public IFormPage getPreviousPage(IFormPage current) {
- IFormPage previousPage = null;
- int i = pages.indexOf(current);
- if (i > -1) {
- ListIterator<CommonActivityExplorerPage> it = pages.listIterator(i);
- if (it.hasPrevious())
- previousPage = it.previous();
- }
- return previousPage;
- }
+ /**
+ * Update the editor Remove and Create pages
+ */
+ public void updateEditorPages(int activatedPage) {
+ removeAllPages();
+ addPages();
+ setActivePage(activatedPage); // we set the page ProcessMap activate
+ setPartName(getPartName());
+ }
- /**
- * Get the next page
- *
- * @param current
- * @return the next page or null
- */
- @SuppressWarnings("unchecked")
- public IFormPage getNextPage(IFormPage current) {
- IFormPage nextPage = null;
- int i = pages.indexOf(current);
- if (i > -1) {
- ListIterator<CommonActivityExplorerPage> it = pages.listIterator(i + 1);
- if (it.hasNext())
- nextPage = it.next();
- }
- return nextPage;
- }
+ /**
+ * Handle property change.<br>
+ * @param event
+ * @param value
+ * @param property
+ * @return boolean
+ */
+ protected boolean doPropertyChange(PropertyChangeEvent event, boolean value, String property) {
+ boolean result = false;
+ if (ActivityExplorerExtensionManager.isPage(property)) {
+ this.updateEditorPages(0);
+ result = true;
+ }
+ return result;
+ }
- /**
- * Update the editor Remove and Create pages
- */
- public void updateEditorPages(int activatedPage) {
+ @Override
+ public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
+ String property = event.getProperty();
+ boolean value = ((Boolean) event.getNewValue()).booleanValue();
+ if (doPropertyChange(event, value, property)) {
+ if (ActivityExplorerManager.INSTANCE.getEditor() != null) {
+ ActivityExplorerManager.INSTANCE.getEditor().getActivePageInstance().getManagedForm().reflow(true);
+ }
+ }
- removeAllPages();
- addPages();
- setActivePage(activatedPage); // we set the page ProcessMap activate
- setPartName(getPartName());
- }
-
- /**
- * Handle property change.<br>
- *
- * @param event
- * @param value
- * @param property
- * @return boolean
- */
- protected boolean doPropertyChange(PropertyChangeEvent event, boolean value, String property) {
- boolean result = false;
- if (ActivityExplorerExtensionManager.isPage(property)) {
- this.updateEditorPages(0);
- result = true;
- }
- return result;
- }
-
- @Override
- public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
- String property = event.getProperty();
- boolean value = ((Boolean) event.getNewValue()).booleanValue();
- if (doPropertyChange(event, value, property)) {
- if (ActivityExplorerManager.INSTANCE.getEditor() != null)
- ActivityExplorerManager.INSTANCE.getEditor().getActivePageInstance().getManagedForm().reflow(true);
- }
-
- }
+ }
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
index 82a4d6d..aec40f1 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
@@ -50,7 +50,6 @@
/**
* Base class to implement architecture Activity Explorer page.
- *
*/
public class ActivityExplorerPage extends CommonActivityExplorerPage implements IPropertyChangeListener {
@@ -81,24 +80,23 @@
/**
* Adjust image href.
- *
* @param richText
- * @param used
- * to collect image.
+ * @param used to collect image.
*/
protected void adjustImageHRef(FormText richText, ActivityExplorerActivator activator) {
- if (headerImageOff != null)
+ if (headerImageOff != null) {
adjustImageHRef(richText, headerImageOff, getId());
+ }
}
protected void adjustImageHRef(FormText richText, Image image, String id) {
- if (image != null)
+ if (image != null) {
richText.setImage(id, image);
+ }
}
/**
* Create contributed sections but not initialize it
- *
*/
private void createContributedSections() {
// Loop over pages contributors.
@@ -123,15 +121,15 @@
protected List<ActivityExplorerSection> getVisibleSections() {
List<ActivityExplorerSection> visibleSections = new ArrayList<ActivityExplorerSection>();
for (ActivityExplorerSection s : getSections()) {
- if (s.isVisible())
+ if (s.isVisible()) {
visibleSections.add(s);
+ }
}
return visibleSections;
}
/**
* Initialize the sections
- *
* @param section
* @param sectionContainer
* @param managedForm
@@ -190,7 +188,6 @@
/**
* Create the overview section.
- *
* @param sectionContainer
* @param managedForm
* @return
@@ -203,16 +200,19 @@
// create rich text
String body = HTMLHelper.breadcrumbForm(previousPage, this, nextPage);
- FormText richText = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.FormHelper.createRichText(
- managedForm.getToolkit(), sectionContainer, body, new FormTextPageLinkAdapter(getEditor()));
+ FormText richText =
+ org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.FormHelper.createRichText(managedForm.getToolkit(), sectionContainer, body,
+ new FormTextPageLinkAdapter(getEditor()));
// attach image to link
adjustImageHRef(richText, getHeaderImageOn(), getId());
- if (previousPage != null && previousPage instanceof ActivityExplorerPage)
+ if ((previousPage != null) && (previousPage instanceof ActivityExplorerPage)) {
adjustImageHRef(richText, ((ActivityExplorerPage) previousPage).getHeaderImageOff(), previousPage.getId());
- if (nextPage != null && nextPage instanceof ActivityExplorerPage)
+ }
+ if ((nextPage != null) && (nextPage instanceof ActivityExplorerPage)) {
adjustImageHRef(richText, ((ActivityExplorerPage) nextPage).getHeaderImageOff(), nextPage.getId());
+ }
richText.marginHeight = 0;
richText.marginWidth = 0;
@@ -222,13 +222,13 @@
/**
* Create the container that hosts sections.<br>
* This one layouts its content using a {@link TableWrapLayout} to allow sections to have wrapped hyper controls.
- *
* @param parent
* @param managedForm
*/
protected Composite createSectionContainer(Composite parent, IManagedForm managedForm) {
- Composite container = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.FormHelper
- .createCompositeWithLayoutType(managedForm.getToolkit(), parent, LayoutType.TABLEWRAP_LAYOUT, 1, true);
+ Composite container =
+ org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.FormHelper.createCompositeWithLayoutType(managedForm.getToolkit(), parent,
+ LayoutType.TABLEWRAP_LAYOUT, 1, true);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
return container;
}
@@ -236,15 +236,13 @@
/**
* Create section displayed in this page.<br>
* Default implementation return <code>null</code>.
- *
* @param sectionContainer
* @return First created section. This one is used to enable UI alignment with Diagram viewer section.
*/
protected void createHeaderSections(final Composite sectionContainer, IManagedForm managedForm) {
// Create Overview section.
- AbstractDescriptionAction displayDescription = new DescriptionAction(sectionContainer.getShell(),
- getPageDescription());
+ AbstractDescriptionAction displayDescription = new DescriptionAction(sectionContainer.getShell(), getPageDescription());
Form formWidget = managedForm.getForm().getForm();
formWidget.getMenuManager().add(displayDescription);
formWidget.getToolBarManager().add(displayDescription);
@@ -266,7 +264,6 @@
/**
* Handle property change.<br>
- *
* @param event
* @param value
* @param property
@@ -286,7 +283,6 @@
/**
* Test if the id is a Activity Explorer page.
- *
* @param id
* @return boolean
*/
@@ -296,7 +292,6 @@
/**
* Get a ActivityExplorerSection in the page from its id.
- *
* @param id
*/
protected ActivityExplorerSection getSectionById(final String id) {
@@ -327,7 +322,6 @@
/**
* Get the header page title.
- *
* @return
*/
protected String getHeaderTitle() {
@@ -336,7 +330,6 @@
/**
* Set the header page title.
- *
* @param title
*/
protected void setHeaderTitle(String title) {
@@ -346,7 +339,6 @@
/**
* Get the XML file that defines the form text content for the description of the page.<br>
* Returned path must be relative to <code>org.eclipse.amalgam.explorer.activity.ui/xml</code> folder.<br>
- *
* @return
*/
public String getPageDescription() {
@@ -355,7 +347,6 @@
/**
* Get the section container.
- *
* @return the sectionContainer
*/
protected Composite getSectionContainer() {
@@ -368,7 +359,6 @@
/**
* Handle contributed sections for specified Activity Explorer page provider.
- *
* @param contributor
*/
protected void handleContributedSectionsFor(IConfigurationElement contributor) {
@@ -377,8 +367,7 @@
ActivityExplorerSection section = new ActivityExplorerSection(contributor) {
@Override
protected IAction[] getToolBarActions() {
- IAction[] toolbarActions = new IAction[] { new DescriptionAction(
- ActivityExplorerPage.this.getSite().getShell(), description)
+ IAction[] toolbarActions = new IAction[] { new DescriptionAction(ActivityExplorerPage.this.getSite().getShell(), description)
};
@@ -413,8 +402,9 @@
boolean value = ((Boolean) event.getNewValue()).booleanValue();
if (doPropertyChange(event, value, property)) {
- if (ActivityExplorerManager.INSTANCE.getEditor() != null)
+ if (ActivityExplorerManager.INSTANCE.getEditor() != null) {
ActivityExplorerManager.INSTANCE.getEditor().getActivePageInstance().getManagedForm().reflow(true);
+ }
}
}
@@ -425,9 +415,6 @@
public void setActive(boolean active) {
super.setActive(active);
if (active) {
- // Set a new selection to the property sheet page on Activity Explorer page
- // activation.
- // setCurrentPageSelectionToPropertySheetPage();
updateActionBars();
}
}
@@ -437,15 +424,13 @@
* {@link #getViewer()}.
*/
/*
- * protected void setCurrentPageSelectionToPropertySheetPage() { // Call the property sheet page without loading it.
- * // Indeed, we won't load it if the view is not displayed. TabbedPropertySheetPage propertySheetPage =
- * getEditor().getPropertySheetPage(); if (null != propertySheetPage) {
+ * protected void setCurrentPageSelectionToPropertySheetPage() { // Call the property sheet page without loading it. // Indeed, we won't load it if the view
+ * is not displayed. TabbedPropertySheetPage propertySheetPage = getEditor().getPropertySheetPage(); if (null != propertySheetPage) {
* propertySheetPage.selectionChanged(getEditor(), getViewer().getSelection()); } }
*/
/**
* Update action bars (handlers).
- *
* @param editorActionBars
*/
public void updateActionBars() {
@@ -458,6 +443,7 @@
/**
* Initialize the Page with parameters.
*/
+ @Override
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
super.setInitializationData(cfig, propertyName, data);
@@ -477,14 +463,14 @@
}
String description = ActivityExplorerExtensionManager.getDescription(cfig);
- if (null != description)
+ if (null != description) {
setPageDescription(HTMLHelper.formWrapper(description));
+ }
}
/**
* Set the page description.
- *
* @param description
*/
@@ -494,7 +480,6 @@
/**
* Set Header Image Off.
- *
* @param image
*/
protected void setHeaderImageOff(Image image) {
@@ -504,7 +489,6 @@
/**
* Set Header Image On.
- *
* @param image
*/
protected void setHeaderImageOn(Image image) {
@@ -514,7 +498,6 @@
/**
* Get Image Off.
- *
* @return Image
*/
public Image getHeaderImageOff() {
@@ -523,7 +506,6 @@
/**
* Get header image On.
- *
* @return Image
*/
public Image getHeaderImageOn() {
@@ -544,10 +526,10 @@
/**
* Get the applied Predicate.
- *
* @return {@link IPredicate}
*/
public IPredicate getPredicate() {
return predicate;
}
+
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/BasicSessionActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/BasicSessionActivityExplorerPage.java
index 5211f52..7f2ca00 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/BasicSessionActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/BasicSessionActivityExplorerPage.java
@@ -11,7 +11,6 @@
package org.eclipse.amalgam.explorer.activity.ui.api.editor.pages;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.eclipse.amalgam.explorer.activity.ui.ActivityExplorerActivator;
@@ -35,12 +34,10 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.sirius.business.api.session.Session;
-import org.eclipse.sirius.business.api.session.SessionListener;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.events.IHyperlinkListener;
@@ -49,472 +46,348 @@
/**
* Base class to implement basic session Activity Explorer page.
- *
*/
public class BasicSessionActivityExplorerPage extends ActivityExplorerPage {
- /**
- * Diagrams Viewer weight (used by the sash).ContentProvider
- */
- private static final int DIAGRAMS_VIEWER_WEIGHT = 40;
+ /**
+ * Diagrams Viewer weight (used by the sash).ContentProvider
+ */
+ private static final int DIAGRAMS_VIEWER_WEIGHT = 40;
- /**
- * ActivityExplorerSection weight (used by the sash).
- */
- private static final int SECTION_WEIGHT = 60;
+ /**
+ * ActivityExplorerSection weight (used by the sash).
+ */
+ private static final int SECTION_WEIGHT = 60;
- /**
- * Used to flag if current page is dirty.
- */
- private volatile boolean _isDirty;
+ /**
+ * Container that hosts the viewer.
+ */
+ private Composite _viewerContainer;
- /**
- * Container that hosts the viewer.
- */
- private Composite _viewerContainer;
+ /**
+ * List of Viewers in the current page
+ */
+ private Set<AbstractActivityExplorerViewer> viewers = new HashSet<AbstractActivityExplorerViewer>();
- /**
- * Our session listener
- */
- private SessionListener _sessionListener;
+ /**
+ * define if viewer should appears in the page
+ */
+ private boolean displayViewer;
- /**
- * List of Viewers in the current page
- */
- private Set<AbstractActivityExplorerViewer> viewers = new HashSet<AbstractActivityExplorerViewer>();
+ @Override
+ protected void createHeaderSections(Composite sectionContainer_p, IManagedForm managedForm_p) {
- /**
- * define if viewer should appears in the page
- */
- private boolean displayViewer;
+ // Create Overview section.
- @Override
- protected void createHeaderSections(Composite sectionContainer_p, IManagedForm managedForm_p) {
+ final Form formWidget = managedForm_p.getForm().getForm();
- // Create Overview section.
+ // init
+ formWidget.getMenuManager().add(new Separator("empty-list")); //$NON-NLS-1$
- final Form formWidget = managedForm_p.getForm().getForm();
+ // add listener
+ formWidget.getMenuManager().addMenuListener(new IMenuListener2() {
- // init
- formWidget.getMenuManager().add(new Separator("empty-list")); //$NON-NLS-1$
+ public void menuAboutToShow(IMenuManager manager) {
- // add listener
- formWidget.getMenuManager().addMenuListener(new IMenuListener2() {
+ manager.removeAll();
- public void menuAboutToShow(IMenuManager manager) {
+ for (Session session : SessionManager.INSTANCE.getSessions()) {
- manager.removeAll();
+ if (!session.equals(BasicSessionActivityExplorerPage.this.getEditorInput().getSession())) {
+ formWidget.getMenuManager().add(new OpenActivityExplorerAction2(session));
+ }
+ }
- for (Session session : SessionManager.INSTANCE.getSessions()) {
+ }
- if (!session.equals(BasicSessionActivityExplorerPage.this.getEditorInput().getSession()))
- formWidget.getMenuManager().add(new OpenActivityExplorerAction2(session));
- }
+ public void menuAboutToHide(IMenuManager manager) {
- }
+ }
- public void menuAboutToHide(IMenuManager manager) {
+ });
- }
+ formWidget.getToolBarManager().update(true);
- });
+ createOverviewSection(sectionContainer_p, managedForm_p);
+ }
- formWidget.getToolBarManager().update(true);
+ @Override
+ protected void createFormContent(IManagedForm managedForm_p) {
+ super.createFormContent(managedForm_p);
- createOverviewSection(sectionContainer_p, managedForm_p);
- }
+ if (displayViewer) {
+ MDSashForm sashForm = (MDSashForm) getSectionContainer().getParent();
+ _viewerContainer = createViewerContainer(sashForm, managedForm_p);
+ _viewerContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
- @Override
- protected void createFormContent(IManagedForm managedForm_p) {
- super.createFormContent(managedForm_p);
+ // create viewers
+ createViewers(_viewerContainer, managedForm_p);
- if (displayViewer) {
- MDSashForm sashForm = (MDSashForm) getSectionContainer().getParent();
- _viewerContainer = createViewerContainer(sashForm, managedForm_p);
- _viewerContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // Hook resize listener for the sash behavior.
+ hookResizeListener();
- // create viewers
- createViewers(_viewerContainer, managedForm_p);
+ // 66% 34 % weights for the sash.
+ sashForm.setWeights(new int[] { SECTION_WEIGHT, DIAGRAMS_VIEWER_WEIGHT });
- // Hook resize listener for the sash behavior.
- hookResizeListener();
+ // Force a layout to make sure, page is well refreshed.
+ managedForm_p.reflow(true);
- // 66% 34 % weights for the sash.
- sashForm.setWeights(new int[] { SECTION_WEIGHT, DIAGRAMS_VIEWER_WEIGHT });
+ }
+ }
- // Force a layout to make sure, page is well refreshed.
- managedForm_p.reflow(true);
+ /**
+ * defines the type of particular viewer that should be adding to the page.
+ */
+ @SuppressWarnings("unchecked")
+ protected Class<? extends AbstractActivityExplorerViewer>[] addViewersTypeInPage() {
+ return new Class[] { DiagramViewer.class };
+ }
- addSessionListener();
- }
- }
+ /**
+ * create and add a viewer in the page.
+ * @param viewerContainer_p
+ * @param managedForm_p
+ */
+ private void createViewers(Composite viewerContainer_p, IManagedForm managedForm_p) {
+ Class<? extends AbstractActivityExplorerViewer>[] viewerTab = addViewersTypeInPage();
+ for (Class<? extends AbstractActivityExplorerViewer> viewer : viewerTab) {
+ AbstractActivityExplorerViewer newViewer = addNewViewer(viewer);
+ newViewer.createViewer(viewerContainer_p, managedForm_p);
+ }
+ }
- /**
- * Add a session listener in order to set the page in dirty
- */
- protected void addSessionListener() {
- SessionListener _sessionListener = new SessionListener() {
- public void notify(int changeKind_p) {
- if (changeKind_p == SessionListener.REPLACED || changeKind_p == SessionListener.SYNC) {
- markAsDirty();
- }
- }
- };
- this.getEditorInput().getSession().addListener(_sessionListener);
- }
+ /**
+ * Allows to add a new Viewer
+ * @param viewer
+ */
+ protected final AbstractActivityExplorerViewer addNewViewer(Class<? extends AbstractActivityExplorerViewer> viewer) {
+ AbstractActivityExplorerViewer newViewer = null;
+ try {
+ newViewer = viewer.getConstructor(BasicSessionActivityExplorerPage.class).newInstance(this);
+ viewers.add(newViewer);
+ } catch (Exception ex) {
+ ActivityExplorerActivator.getDefault().sentToLogger(ex);
+ }
- /**
- * defines the type of particular viewer that should be adding to the page.
- *
- */
- @SuppressWarnings("unchecked")
- protected Class<? extends AbstractActivityExplorerViewer>[] addViewersTypeInPage() {
- return new Class[] { DiagramViewer.class };
- }
+ return newViewer;
+ }
- /**
- * create and add a viewer in the page.
- *
- * @param viewerContainer_p
- * @param managedForm_p
- */
- private void createViewers(Composite viewerContainer_p, IManagedForm managedForm_p) {
- Class<? extends AbstractActivityExplorerViewer>[] viewerTab = addViewersTypeInPage();
- for (Class<? extends AbstractActivityExplorerViewer> viewer : viewerTab) {
- AbstractActivityExplorerViewer newViewer = addNewViewer(viewer);
- newViewer.createViewer(viewerContainer_p, managedForm_p);
- }
- }
+ /**
+ * Create the viewer that displays diagrams.
+ * @param viewerContainer_p
+ * @param managedForm_p
+ */
+ /*
+ * protected Couple<TreeViewer, Section> createViewer(Composite viewerContainer_p, IManagedForm managedForm_p) { // Create the section. Couple<Section,
+ * Composite> section = FormHelper.createSectionWithDescription(managedForm_p.getToolkit(), viewerContainer_p, getViewerSectionTitle(), null);
+ * FormHelper.createSectionToolbar(section.getKey(), Collections.singletonList(getResetSectionFilter())); section.getKey().setLayoutData(new
+ * GridData(GridData.FILL_BOTH)); // Create a tree viewer with a regular expression filter. PatternFilter patternFilter = new PatternFilter();
+ * @SuppressWarnings("deprecation") FilteredTree filteredTree = new FilteredTree(section.getValue(),SWT.NONE | SWT.SINGLE | SWT.BORDER, patternFilter);
+ * managedForm_p.getToolkit().adapt(filteredTree); // Get the tree viewer. final TreeViewer treeViewer = filteredTree.getViewer(); // Add double click
+ * listener to open double-clicked diagrams. addListenersOnViewer(treeViewer); // Add the filter driven by section. _diagramViewerFilter = new
+ * DelegatedViewerFilter(); treeViewer.addFilter(_diagramViewerFilter); // Set content provider. treeViewer.setContentProvider(getContentProvider()); // Set
+ * label provider. treeViewer.setLabelProvider(getLabelProvider()); // Auto expand the root node. treeViewer.setAutoExpandLevel(2); // Set the initial input.
+ * Also make sure to refresh the viewer if underlying // resources change. _sessionListener = new SessionListener() { public void notify(int changeKind_p) {
+ * if (changeKind_p == SessionListener.REPLACED) { markDiagramViewerAsDirty(); } } }; this.getEditorInput().getSession().addListener(_sessionListener);
+ * treeViewer.setInput(getInput()); // Forward selection changes to the editor site selection provider to notify the platform (e.g property view).
+ * treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ *//**
+ * {@inheritDoc}
+ */
+ /*
+ * public void selectionChanged(SelectionChangedEvent event_p) { getEditorSite ().getSelectionProvider().setSelection(event_p.getSelection()); } }); // Make a
+ * context menu for the tree viewer. makeViewerActions(treeViewer); return new Couple<TreeViewer, Section>(treeViewer, section.getKey()); } protected String
+ * getViewerSectionTitle() { return Messages.BasicSessionActivityExplorerPage_0; }
+ */
- /**
- * Allows to add a new Viewer
- *
- * @param viewer
- */
- protected final AbstractActivityExplorerViewer addNewViewer(Class<? extends AbstractActivityExplorerViewer> viewer) {
- AbstractActivityExplorerViewer newViewer = null;
- try {
- newViewer = viewer.getConstructor(BasicSessionActivityExplorerPage.class).newInstance(this);
- viewers.add(newViewer);
- } catch (Exception ex) {
- ActivityExplorerActivator.getDefault().sentToLogger(ex);
- }
+ /*
+ * protected Object getInput() { return getEditorInput().getSession(); } protected ILabelProvider getLabelProvider() { return new
+ * ViewpointCommonLabelProvider(); }
+ */
- return newViewer;
- }
+ /**
+ * Create viewer container that hosts the viewer.<br>
+ * This one layouts its content using a {@link GridLayout}.
+ * @param parent_p
+ * @param managedForm_p
+ * @return
+ */
+ protected Composite createViewerContainer(Composite parent_p, IManagedForm managedForm_p) {
+ return FormHelper.createCompositeWithLayoutType(managedForm_p.getToolkit(), parent_p, LayoutType.GRID_LAYOUT, 1, true);
+ }
- /**
- * Create the viewer that displays diagrams.
- *
- * @param viewerContainer_p
- * @param managedForm_p
- */
- /*
- * protected Couple<TreeViewer, Section> createViewer(Composite
- * viewerContainer_p, IManagedForm managedForm_p) { // Create the section.
- * Couple<Section, Composite> section =
- * FormHelper.createSectionWithDescription(managedForm_p.getToolkit(),
- * viewerContainer_p, getViewerSectionTitle(), null);
- * FormHelper.createSectionToolbar(section.getKey(),
- * Collections.singletonList(getResetSectionFilter()));
- * section.getKey().setLayoutData(new GridData(GridData.FILL_BOTH)); //
- * Create a tree viewer with a regular expression filter. PatternFilter
- * patternFilter = new PatternFilter();
- *
- * @SuppressWarnings("deprecation") FilteredTree filteredTree = new
- * FilteredTree(section.getValue(),SWT.NONE | SWT.SINGLE | SWT.BORDER,
- * patternFilter);
- *
- * managedForm_p.getToolkit().adapt(filteredTree); // Get the tree viewer.
- * final TreeViewer treeViewer = filteredTree.getViewer(); // Add double
- * click listener to open double-clicked diagrams.
- * addListenersOnViewer(treeViewer); // Add the filter driven by section.
- * _diagramViewerFilter = new DelegatedViewerFilter();
- * treeViewer.addFilter(_diagramViewerFilter); // Set content provider.
- * treeViewer.setContentProvider(getContentProvider()); // Set label
- * provider. treeViewer.setLabelProvider(getLabelProvider()); // Auto expand
- * the root node. treeViewer.setAutoExpandLevel(2);
- *
- * // Set the initial input. Also make sure to refresh the viewer if
- * underlying // resources change.
- *
- * _sessionListener = new SessionListener() { public void notify(int
- * changeKind_p) { if (changeKind_p == SessionListener.REPLACED) {
- * markDiagramViewerAsDirty(); } } };
- *
- * this.getEditorInput().getSession().addListener(_sessionListener);
- * treeViewer.setInput(getInput());
- *
- * // Forward selection changes to the editor site selection provider to
- * notify the platform (e.g property view).
- * treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- *//**
- * {@inheritDoc}
- */
- /*
- * public void selectionChanged(SelectionChangedEvent event_p) {
- * getEditorSite
- * ().getSelectionProvider().setSelection(event_p.getSelection()); } }); //
- * Make a context menu for the tree viewer. makeViewerActions(treeViewer);
- * return new Couple<TreeViewer, Section>(treeViewer, section.getKey()); }
- *
- * protected String getViewerSectionTitle() { return
- * Messages.BasicSessionActivityExplorerPage_0; }
- */
+ /**
+ * @see org.eclipse.ui.forms.editor.FormPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Unregister as property listener.
+ ActivityExplorerActivator.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+ // Dispose viewer actions.
- /*
- * protected Object getInput() { return getEditorInput().getSession(); }
- *
- *
- *
- * protected ILabelProvider getLabelProvider() { return new
- * ViewpointCommonLabelProvider(); }
- */
+ for (AbstractActivityExplorerViewer viewer : viewers) {
+ viewer.dispose();
+ }
+ // clean the viewers' list
+ viewers.clear();
- /**
- * Create viewer container that hosts the viewer.<br>
- * This one layouts its content using a {@link GridLayout}.
- *
- * @param parent_p
- * @param managedForm_p
- * @return
- */
- protected Composite createViewerContainer(Composite parent_p, IManagedForm managedForm_p) {
- return FormHelper.createCompositeWithLayoutType(managedForm_p.getToolkit(), parent_p, LayoutType.GRID_LAYOUT,
- 1, true);
- }
+ super.dispose();
+ }
- /**
- * @see org.eclipse.ui.forms.editor.FormPage#dispose()
- */
- @Override
- public void dispose() {
- // Unregister as property listener.
- ActivityExplorerActivator.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- // Dispose viewer actions.
-
- if (null != _sessionListener) {
- this.getEditorInput().getSession().removeListener(_sessionListener);
- }
-
- for (AbstractActivityExplorerViewer viewer : viewers)
- viewer.dispose();
- // clean the viewers' list
- viewers.clear();
-
- super.dispose();
- }
-
- /**
- * Get the viewpoint handled by this page.
- *
- * @return an empty string.
- */
- public Set<String> getHandledViewpoint() {
- Set<String> vps = new HashSet<String>();
- for (org.eclipse.amalgam.explorer.activity.ui.api.editor.sections.ActivityExplorerSection section : getSections()) {
- for (ExplorerActivity activity : section.getActivities()) {
- IHyperlinkListener listener = activity.getListener();
- if (listener instanceof AbstractNewDiagramHyperlinkAdapter)
- vps.add(((AbstractNewDiagramHyperlinkAdapter) listener).getRepresentationName());
- }
- }
- return vps;
- }
-
-
- /**
- * Handle contributed sections for specified ActivityExplorerPagesProvider.
- *
- * @param contributor_p
- * @param sectionContainer_p
- * @param managedForm_p
- */
- @Override
- protected void handleContributedSectionsFor(IConfigurationElement contributor_p) {
-
- // create the session
- ActivityExplorerSection newSection = new ActivityExplorerSection(contributor_p) {
- @Override
- protected IAction[] getToolBarActions() {
-
- IAction[] toolbarActions = new IAction[] {
- new DescriptionAction(BasicSessionActivityExplorerPage.this.getSite().getShell(), getDescription()),
- new ViewerFilteringAction(BasicSessionActivityExplorerPage.this, this) };
-
- if (!isFiltering())
- toolbarActions = new IAction[] { new DescriptionAction(BasicSessionActivityExplorerPage.this.getSite()
- .getShell(), getDescription()), };
-
- return toolbarActions;
- }
- };
-
- // inserts sections in page
- boolean value = getSections().add(newSection);
- if (!value) {
- ActivityExplorerActivator
- .getDefault()
- .getLog()
- .log(new Status(IStatus.ERROR, ActivityExplorerActivator.ID, "The declared section: " + newSection.getId()
- + " has the same index of a another section. Changes it!")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
+ /**
+ * Get the viewpoint handled by this page.
+ * @return an empty string.
+ */
+ public Set<String> getHandledViewpoint() {
+ Set<String> vps = new HashSet<String>();
+ for (org.eclipse.amalgam.explorer.activity.ui.api.editor.sections.ActivityExplorerSection section : getSections()) {
+ for (ExplorerActivity activity : section.getActivities()) {
+ IHyperlinkListener listener = activity.getListener();
+ if (listener instanceof AbstractNewDiagramHyperlinkAdapter) {
+ vps.add(((AbstractNewDiagramHyperlinkAdapter) listener).getRepresentationName());
+ }
+ }
+ }
+ return vps;
+ }
- /**
- * Mark pages as dirty.
- */
- public void markAsDirty() {
- // If active, refresh it directly.
- if (isActive()) {
- refreshViewers();
- } else {
- _isDirty = true;
- }
- }
+ /**
+ * Handle contributed sections for specified ActivityExplorerPagesProvider.
+ * @param contributor_p
+ * @param sectionContainer_p
+ * @param managedForm_p
+ */
+ @Override
+ protected void handleContributedSectionsFor(IConfigurationElement contributor_p) {
- /**
- * Refresh the viewers.
- */
- private void refreshViewers() {
- Display current = Display.getCurrent();
- if (current != null) {
- current.asyncExec(new Runnable() {
+ // create the session
+ ActivityExplorerSection newSection = new ActivityExplorerSection(contributor_p) {
+ @Override
+ protected IAction[] getToolBarActions() {
- @Override
- public void run() {
- if (!viewers.isEmpty()) {
- Iterator<AbstractActivityExplorerViewer> it = viewers.iterator();
- while (it.hasNext()) {
- AbstractActivityExplorerViewer viewer = it.next();
- viewer.refresh();
- }
- }
+ IAction[] toolbarActions =
+ new IAction[] { new DescriptionAction(BasicSessionActivityExplorerPage.this.getSite().getShell(), getDescription()),
+ new ViewerFilteringAction(BasicSessionActivityExplorerPage.this, this) };
- }
- });
- }
+ if (!isFiltering()) {
+ toolbarActions = new IAction[] { new DescriptionAction(BasicSessionActivityExplorerPage.this.getSite().getShell(), getDescription()), };
+ }
- }
+ return toolbarActions;
+ }
+ };
- /**
- * Refresh the diagram viewer.
- */
- /*
- * public void refreshDiagramViewer() { if ((null != _viewer) &&
- * !_viewer.getControl().isDisposed()) { getViewer().refresh(); _isDirty =
- * false; } }
- */
- /**
- * @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean)
- */
- @Override
- public void setActive(boolean active_p) {
- super.setActive(active_p);
- if (active_p) {
- // Set a new selection to the property sheet page on Activity Explorer page
- // activation.
- setCurrentPageSelectionToPropertySheetPage();
- // If active and dirty, refreshes the diagram viewer.
- if (_isDirty) {
- refreshViewers();
- }
- updateActionBars();
- }
- }
+ // inserts sections in page
+ boolean value = getSections().add(newSection);
+ if (!value) {
+ ActivityExplorerActivator
+ .getDefault()
+ .getLog()
+ .log(
+ new Status(IStatus.ERROR, ActivityExplorerActivator.ID, "The declared section: " + newSection.getId()
+ + " has the same index of a another section. Changes it!")); //$NON-NLS-1$
+ }
- /**
- * Refresh the property sheet page according to the current viewer
- * selection.<br>
- * {@link #getViewer()}.
- */
- protected void setCurrentPageSelectionToPropertySheetPage() {
- // Call the property sheet page without loading it.
- // Indeed, we won't load it if the view is not displayed.
- TabbedPropertySheetPage propertySheetPage = getEditor().getPropertySheetPage();
+ }
- if (null != propertySheetPage && displayViewer) {
- /*
- * Viewer viewer = getViewer(); if(null!= viewer){ ISelection
- * currentSelection = viewer.getSelection(); if(currentSelection !=
- * null) propertySheetPage.selectionChanged(getEditor(),
- * currentSelection); }
- */// TODO:A modifier pour la prise en compte de plusieurs viewer
- }
- }
+ /**
+ * Refresh the diagram viewer.
+ */
+ /*
+ * public void refreshDiagramViewer() { if ((null != _viewer) && !_viewer.getControl().isDisposed()) { getViewer().refresh(); _isDirty = false; } }
+ */
+ /**
+ * @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean)
+ */
+ @Override
+ public void setActive(boolean active_p) {
+ super.setActive(active_p);
+ if (active_p) {
+ // Set a new selection to the property sheet page on Activity Explorer page
+ // activation.
+ setCurrentPageSelectionToPropertySheetPage();
+ }
+ }
- /**
- * Set a viewer filter on the diagram viewer.
- *
- * @param filter_p
- * <code>null</code> means reset the filter.
- * @param action_p
- */
- public void callViewersFilter(ViewerFilteringAction action_p) {
- // If given filter is null that means reset the filter.
- for (AbstractActivityExplorerViewer viewer : viewers) {
- viewer.setViewerFilter(action_p);
- }
- }
+ /**
+ * Refresh the property sheet page according to the current viewer selection.<br>
+ * {@link #getViewer()}.
+ */
+ protected void setCurrentPageSelectionToPropertySheetPage() {
+ // Call the property sheet page without loading it.
+ // Indeed, we won't load it if the view is not displayed.
+ TabbedPropertySheetPage propertySheetPage = getEditor().getPropertySheetPage();
+ if ((null != propertySheetPage) && displayViewer) {
+ /*
+ * Viewer viewer = getViewer(); if(null!= viewer){ ISelection currentSelection = viewer.getSelection(); if(currentSelection != null)
+ * propertySheetPage.selectionChanged(getEditor(), currentSelection); }
+ */// TODO:A modifier pour la prise en compte de plusieurs viewer
+ }
+ }
+ /**
+ * Set a viewer filter on the diagram viewer.
+ * @param filter_p <code>null</code> means reset the filter.
+ * @param action_p
+ */
+ public void callViewersFilter(ViewerFilteringAction action_p) {
+ // If given filter is null that means reset the filter.
+ for (AbstractActivityExplorerViewer viewer : viewers) {
+ viewer.setViewerFilter(action_p);
+ }
+ }
- /**
- * Uncheck the previous action's section that drove the filter.
- */
- /*
- * private void uncheckSectionFilterAction() { if (null !=
- * _sectionActionDrivingFilter) {
- * _sectionActionDrivingFilter.setChecked(false);
- * _sectionActionDrivingFilter = null; } }
- */
+ /**
+ * Uncheck the previous action's section that drove the filter.
+ */
+ /*
+ * private void uncheckSectionFilterAction() { if (null != _sectionActionDrivingFilter) { _sectionActionDrivingFilter.setChecked(false);
+ * _sectionActionDrivingFilter = null; } }
+ */
- /**
- * Update action bars (handlers).
- *
- * @param editorActionBars
- */
- public void updateActionBars() {
- IActionBars editorActionBars = getEditorSite().getActionBars();
- // editorActionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
- // _deleteRepresentationAction);
- // editorActionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(),
- // _renameRepresentationAction);
- // Update action bars to make sure global ActionHandler are updated
- // accordingly.
- editorActionBars.updateActionBars();
- }
+ /**
+ * Update action bars (handlers).
+ * @param editorActionBars
+ */
+ @Override
+ public void updateActionBars() {
+ IActionBars editorActionBars = getEditorSite().getActionBars();
+ // editorActionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
+ // _deleteRepresentationAction);
+ // editorActionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(),
+ // _renameRepresentationAction);
+ // Update action bars to make sure global ActionHandler are updated
+ // accordingly.
+ editorActionBars.updateActionBars();
+ }
- /**
- * Test if a viewer should be display in the page.
- *
- * @return boolean
- */
- protected boolean isDisplayViewerInPage() {
- return displayViewer;
- }
+ /**
+ * Test if a viewer should be display in the page.
+ * @return boolean
+ */
+ protected boolean isDisplayViewerInPage() {
+ return displayViewer;
+ }
- @Override
- public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
+ @Override
+ public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
- super.setInitializationData(cfig, propertyName, data);
- displayViewer = ActivityExplorerExtensionManager.getIsDisplayViewerInPage(cfig);
+ super.setInitializationData(cfig, propertyName, data);
+ displayViewer = ActivityExplorerExtensionManager.getIsDisplayViewerInPage(cfig);
- }
+ }
- /**
- * Test if the page should be visible. if no sections is visible the page is
- * not visible.
- *
- * @return boolean
- */
- @Override
- public boolean isVisible() {
- boolean result = super.isVisible();
- result &= !getVisibleSections().isEmpty();
+ /**
+ * Test if the page should be visible. if no sections is visible the page is not visible.
+ * @return boolean
+ */
+ @Override
+ public boolean isVisible() {
+ boolean result = super.isVisible();
+ result &= !getVisibleSections().isEmpty();
- return result;
- }
+ return result;
+ }
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java
index b459921..cb4c10c 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java
@@ -20,6 +20,8 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
@@ -28,9 +30,8 @@
/**
* Base class to implement ActivityExplorer pages in an {@link ActivityExplorerEditor}.
- *
*/
-public class CommonActivityExplorerPage extends FormPage implements IExecutableExtension, IOrdered, IVisibility {
+public class CommonActivityExplorerPage extends FormPage implements IExecutableExtension, IOrdered, IVisibility, IPropertyListener {
private boolean overview;
private Image overviewImageOff;
@@ -40,6 +41,8 @@
private String overviewImageOffPath;
protected IPredicate predicate;
+ public static final int PROP_ACTIVE = 0x185;
+
private int index;
private static String ids;
@@ -66,6 +69,9 @@
toolkit.decorateFormHeading(managedForm.getForm().getForm());
// For performance optimization.
// managedForm.getForm().setDelayedReflow(true);
+
+ getEditor().addPropertyListener(this);
+
}
/**
@@ -76,6 +82,7 @@
return (SharedHeaderFormEditor) super.getEditor();
}
+ @Override
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
super.setInitializationData(cfig, propertyName, data);
@@ -83,8 +90,9 @@
String title = ActivityExplorerExtensionManager.getTitle(cfig);
String tabName = ActivityExplorerExtensionManager.getTabName(cfig);
- if (tabName == null)
+ if (tabName == null) {
tabName = title;
+ }
setPartName(tabName);
overview = ActivityExplorerExtensionManager.getOverviewElement(cfig) != null;
@@ -205,4 +213,31 @@
}
+ @Override
+ public void setActive(boolean active) {
+ super.setActive(active);
+ if (active) {
+ markAsActive();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object, int)
+ */
+ @Override
+ public void propertyChanged(Object source, int propId) {
+ if (IEditorPart.PROP_DIRTY == propId) {
+ markAsDirty();
+ }
+ }
+
+ public void markAsDirty() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+
+ public void markAsActive() {
+ firePropertyChange(PROP_ACTIVE);
+ }
+
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/AbstractActivityExplorerViewer.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/AbstractActivityExplorerViewer.java
index 95977f5..498a6b2 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/AbstractActivityExplorerViewer.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/AbstractActivityExplorerViewer.java
@@ -14,6 +14,7 @@
import org.eclipse.amalgam.explorer.activity.ui.api.actions.ViewerFilteringAction;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.BasicSessionActivityExplorerPage;
+import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.CommonActivityExplorerPage;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.Messages;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.FormHelper;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.sections.ActivityExplorerSection;
@@ -33,6 +34,8 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredTree;
@@ -40,208 +43,211 @@
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.Section;
-public abstract class AbstractActivityExplorerViewer {
+public abstract class AbstractActivityExplorerViewer implements IPropertyListener {
- /** Parent Page **/
- protected BasicSessionActivityExplorerPage page;
+ /** Parent Page **/
+ protected BasicSessionActivityExplorerPage page;
- /** Jface Viewer **/
- protected TreeViewer viewer;
+ /** Jface Viewer **/
+ protected TreeViewer viewer;
- /**
- * viewer filter.
- */
- private DelegatedViewerFilter viewerFilter;
+ /**
+ * viewer filter.
+ */
+ private DelegatedViewerFilter viewerFilter;
- /**
- * UI action that triggers a diagram viewer filtering operation.
- */
- private ViewerFilteringAction sectionActionDrivingFilter;
+ /**
+ * UI action that triggers a diagram viewer filtering operation.
+ */
+ private ViewerFilteringAction sectionActionDrivingFilter;
- public AbstractActivityExplorerViewer(BasicSessionActivityExplorerPage page_p) {
- page = page_p;
- }
+ public AbstractActivityExplorerViewer(BasicSessionActivityExplorerPage page_p) {
+ page = page_p;
+ page.addPropertyListener(this);
+ }
- protected abstract String getViewerSectionTitle();
+ protected abstract String getViewerSectionTitle();
- protected abstract Object getInput();
+ protected abstract Object getInput();
- protected abstract ILabelProvider getLabelProvider();
+ protected abstract ILabelProvider getLabelProvider();
- protected abstract IContentProvider getContentProvider();
+ protected abstract IContentProvider getContentProvider();
- /**
- * Create an action to remove the section filter.
- *
- * @return
- */
- public Action getResetSectionFilter() {
- Action resetSectionFilter = new Action() {
- /**
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("synthetic-access")
- @Override
- public void run() {
- viewerFilter.setDelegatedFilter(null);
- uncheckSectionFilterAction();
- getViewer().refresh();
- }
+ /**
+ * Create an action to remove the section filter.
+ * @return
+ */
+ public Action getResetSectionFilter() {
+ Action resetSectionFilter = new Action() {
+ /**
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void run() {
+ viewerFilter.setDelegatedFilter(null);
+ uncheckSectionFilterAction();
+ getViewer().refresh();
+ }
- private StructuredViewer getViewer() {
- return viewer;
- }
- };
- resetSectionFilter.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
- .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
- resetSectionFilter.setToolTipText(Messages.BasicSessionActivityExplorerPage_2);
- return resetSectionFilter;
- }
+ private StructuredViewer getViewer() {
+ return viewer;
+ }
+ };
+ resetSectionFilter.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ resetSectionFilter.setToolTipText(Messages.BasicSessionActivityExplorerPage_2);
+ return resetSectionFilter;
+ }
- /**
- * Set a viewer filter on the diagram viewer.
- *
- * @param filter_p
- * <code>null</code> means reset the filter.
- * @param action_p
- */
- public void setViewerFilter(ViewerFilteringAction action_p) {
+ /**
+ * Set a viewer filter on the diagram viewer.
+ * @param filter_p <code>null</code> means reset the filter.
+ * @param action_p
+ */
+ public void setViewerFilter(ViewerFilteringAction action_p) {
- final ViewerFilter filter_p = action_p != null ? getViewerFilter(action_p.getSection()) : null;
+ final ViewerFilter filter_p = action_p != null ? getViewerFilter(action_p.getSection()) : null;
- // If given filter is null that means reset the filter.
- if (null == filter_p) {
- getResetSectionFilter().run();
- return;
- }
+ // If given filter is null that means reset the filter.
+ if (null == filter_p) {
+ getResetSectionFilter().run();
+ return;
+ }
- viewerFilter.setDelegatedFilter(filter_p);
- Control control = viewer.getControl();
+ viewerFilter.setDelegatedFilter(filter_p);
+ Control control = viewer.getControl();
- try {
- // Switch off redraw
- control.setRedraw(false);
- viewer.collapseAll();
- viewer.refresh();
- viewer.expandAll();
+ try {
+ // Switch off redraw
+ control.setRedraw(false);
+ viewer.collapseAll();
+ viewer.refresh();
+ viewer.expandAll();
- // Uncheck the previous action's section that drove the filter.
- uncheckSectionFilterAction();
- // Keep a reference on the action's section that drives the filter.
- sectionActionDrivingFilter = action_p;
- } finally {
- // Finally, redraw again.
- control.setRedraw(true);
- }
- }
+ // Uncheck the previous action's section that drove the filter.
+ uncheckSectionFilterAction();
+ // Keep a reference on the action's section that drives the filter.
+ sectionActionDrivingFilter = action_p;
+ } finally {
+ // Finally, redraw again.
+ control.setRedraw(true);
+ }
+ }
- protected ViewerFilter getViewerFilter(ActivityExplorerSection section) {
- return null;
- }
+ protected ViewerFilter getViewerFilter(ActivityExplorerSection section) {
+ return null;
+ }
- public Couple<TreeViewer, Section> createViewer(Composite viewerContainer_p, IManagedForm managedForm_p) {
- // Create the section.
- Couple<Section, Composite> section = FormHelper.createSectionWithDescription(managedForm_p.getToolkit(),
- viewerContainer_p, getViewerSectionTitle(), null);
- FormHelper.createSectionToolbar(section.getKey(), Collections.singletonList(getResetSectionFilter()));
- section.getKey().setLayoutData(new GridData(GridData.FILL_BOTH));
- // Create a tree viewer with a regular expression filter.
- PatternFilter patternFilter = new PatternFilter();
+ public Couple<TreeViewer, Section> createViewer(Composite viewerContainer_p, IManagedForm managedForm_p) {
+ // Create the section.
+ Couple<Section, Composite> section = FormHelper.createSectionWithDescription(managedForm_p.getToolkit(), viewerContainer_p, getViewerSectionTitle(), null);
+ FormHelper.createSectionToolbar(section.getKey(), Collections.singletonList(getResetSectionFilter()));
+ section.getKey().setLayoutData(new GridData(GridData.FILL_BOTH));
+ // Create a tree viewer with a regular expression filter.
+ PatternFilter patternFilter = new PatternFilter();
- FilteredTree filteredTree = new FilteredTree(section.getValue(), SWT.NONE | SWT.SINGLE | SWT.BORDER,
- patternFilter, true);
+ FilteredTree filteredTree = new FilteredTree(section.getValue(), SWT.NONE | SWT.SINGLE | SWT.BORDER, patternFilter, true);
- managedForm_p.getToolkit().adapt(filteredTree);
- // Get the tree viewer.
- final TreeViewer treeViewer = filteredTree.getViewer();
- // Add double click listener to open double-clicked diagrams.
- addListenersOnViewer(treeViewer);
- // Add the filter driven by section.
- viewerFilter = new DelegatedViewerFilter();
- treeViewer.addFilter(viewerFilter);
- // Set content provider.
- treeViewer.setContentProvider(getContentProvider());
- // Set label provider.
- treeViewer.setLabelProvider(getLabelProvider());
- // Auto expand the root node.
- treeViewer.setAutoExpandLevel(2);
- viewer = treeViewer;
- // Set the initial input. Also make sure to refresh the viewer if
- // underlying
- // resources change.
+ managedForm_p.getToolkit().adapt(filteredTree);
+ // Get the tree viewer.
+ final TreeViewer treeViewer = filteredTree.getViewer();
+ // Add double click listener to open double-clicked diagrams.
+ addListenersOnViewer(treeViewer);
+ // Add the filter driven by section.
+ viewerFilter = new DelegatedViewerFilter();
+ treeViewer.addFilter(viewerFilter);
+ // Set content provider.
+ treeViewer.setContentProvider(getContentProvider());
+ // Set label provider.
+ treeViewer.setLabelProvider(getLabelProvider());
+ // Auto expand the root node.
+ treeViewer.setAutoExpandLevel(2);
+ viewer = treeViewer;
+ // Set the initial input. Also make sure to refresh the viewer if
+ // underlying
+ // resources change.
- treeViewer.setInput(getInput());
+ treeViewer.setInput(getInput());
- // Forward selection changes to the editor site selection provider to
- // notify the platform (e.g property view).
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(SelectionChangedEvent event_p) {
- page.getEditorSite().getSelectionProvider().setSelection(event_p.getSelection());
- }
- });
- // Make a context menu for the tree viewer.
- initMenuToViewer(treeViewer);
- return new Couple<TreeViewer, Section>(treeViewer, section.getKey());
- }
+ // Forward selection changes to the editor site selection provider to
+ // notify the platform (e.g property view).
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ /**
+ * {@inheritDoc}
+ */
+ public void selectionChanged(SelectionChangedEvent event_p) {
+ page.getEditorSite().getSelectionProvider().setSelection(event_p.getSelection());
+ }
+ });
+ // Make a context menu for the tree viewer.
+ initMenuToViewer(treeViewer);
+ return new Couple<TreeViewer, Section>(treeViewer, section.getKey());
+ }
- /**
- * Uncheck the previous action's section that drove the filter.
- */
- private void uncheckSectionFilterAction() {
- if (null != sectionActionDrivingFilter) {
- sectionActionDrivingFilter.setChecked(false);
- sectionActionDrivingFilter = null;
- }
- }
+ /**
+ * Uncheck the previous action's section that drove the filter.
+ */
+ private void uncheckSectionFilterAction() {
+ if (null != sectionActionDrivingFilter) {
+ sectionActionDrivingFilter.setChecked(false);
+ sectionActionDrivingFilter = null;
+ }
+ }
- protected abstract void addListenersOnViewer(TreeViewer viewer);
+ protected abstract void addListenersOnViewer(TreeViewer viewer);
- /**
- * Refresh the diagram viewer.
- */
- public void refresh() {
- if ((null != viewer) && !viewer.getControl().isDisposed()) {
- viewer.refresh();
+ /**
+ * Refresh the diagram viewer.
+ */
+ public void refresh() {
+ if ((page != null) && page.isActive()) {
+ if ((null != viewer) && !viewer.getControl().isDisposed()) {
+ viewer.refresh();
+ }
+ }
+ }
- }
- }
+ /**
+ * Dispose viewer
+ */
+ public void dispose() {
+ viewer.getControl().dispose();
+ }
- /**
- * Dispose viewer
- */
- public void dispose() {
- viewer.getControl().dispose();
- }
+ /**
+ * Make a contextual menu for specified viewer.
+ * @param treeViewer_p
+ */
+ protected MenuManager initMenuToViewer(final TreeViewer treeViewer_p) {
+ MenuManager contextMenuManager = new MenuManager("viewerPopup"); //$NON-NLS-1$
- /**
- * Make a contextual menu for specified viewer.
- *
- * @param treeViewer_p
- */
- protected MenuManager initMenuToViewer(final TreeViewer treeViewer_p) {
- MenuManager contextMenuManager = new MenuManager("viewerPopup"); //$NON-NLS-1$
+ Control control = treeViewer_p.getControl();
+ // Add here some actions.
+ declareViewerActions(contextMenuManager, treeViewer_p);
+ Menu contextMenu = contextMenuManager.createContextMenu(control);
+ control.setMenu(contextMenu);
+ // Hook the menu into the Workbench and its declarative action
+ // mechanisms.
+ page.getEditorSite().registerContextMenu(contextMenuManager, treeViewer_p);
+ return contextMenuManager;
+ }
- Control control = treeViewer_p.getControl();
- // Add here some actions.
- declareViewerActions(contextMenuManager, treeViewer_p);
- Menu contextMenu = contextMenuManager.createContextMenu(control);
- control.setMenu(contextMenu);
- // Hook the menu into the Workbench and its declarative action
- // mechanisms.
- page.getEditorSite().registerContextMenu(contextMenuManager, treeViewer_p);
- return contextMenuManager;
- }
+ /**
+ * Declare viewer actions.<br>
+ * This methods is called eache time the menu is pop-up.
+ * @param contextMenuManager_p
+ * @param treeViewer_p
+ */
+ protected abstract void declareViewerActions(MenuManager contextMenuManager_p, TreeViewer treeViewer_p);
- /**
- * Declare viewer actions.<br>
- * This methods is called eache time the menu is pop-up.
- *
- * @param contextMenuManager_p
- * @param treeViewer_p
- */
- protected abstract void declareViewerActions(MenuManager contextMenuManager_p, TreeViewer treeViewer_p);
-
+ @Override
+ public void propertyChanged(Object source, int propId) {
+ if (CommonActivityExplorerPage.PROP_ACTIVE == propId) {
+ refresh();
+ }
+ if (IEditorPart.PROP_DIRTY == propId) {
+ refresh();
+ }
+ }
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/DiagramViewer.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/DiagramViewer.java
index 245a605..cd3a667 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/DiagramViewer.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/viewers/DiagramViewer.java
@@ -57,304 +57,294 @@
public class DiagramViewer extends AbstractActivityExplorerViewer {
- public DiagramViewer(BasicSessionActivityExplorerPage page_p) {
- super(page_p);
- }
+ private static final String GROUP_MOVE = "Move"; //$NON-NLS-1$
+ private MoveRepresentationAction _moveDiagramAction;
+ private OpenRepresentationsAction _openRepresentation;
+ private RenameRepresentationAction _renameRepresentationAction;
+ private BaseSelectionListenerAction _showInModelExplorerAction;
+ private CloneAction _cloneAction;
+ private DeleteRepresentationAction _deleteRepresentationAction;
- /** Actions **/
+ public DiagramViewer(BasicSessionActivityExplorerPage page_p) {
+ super(page_p);
+ }
- private static final String GROUP_MOVE = "Move"; //$NON-NLS-1$
- private MoveRepresentationAction _moveDiagramAction;
- private OpenRepresentationsAction _openRepresentation;
- private RenameRepresentationAction _renameRepresentationAction;
- private BaseSelectionListenerAction _showInModelExplorerAction;
- private CloneAction _cloneAction;
- private DeleteRepresentationAction _deleteRepresentationAction;
+ @Override
+ protected String getViewerSectionTitle() {
+ return Messages.BasicSessionActivityExplorerPage_0;
+ }
- @Override
- protected String getViewerSectionTitle() {
- return Messages.BasicSessionActivityExplorerPage_0;
- }
+ @Override
+ protected Object getInput() {
+ return page.getEditorInput().getSession();
+ }
- @Override
- protected Object getInput() {
- return page.getEditorInput().getSession();
- }
+ @Override
+ protected ILabelProvider getLabelProvider() {
+ return new SiriusCommonLabelProvider();
+ }
- @Override
- protected ILabelProvider getLabelProvider() {
- return new SiriusCommonLabelProvider();
- }
+ @Override
+ protected IContentProvider getContentProvider() {
+ return new DiagramViewerContentProvider(page.getHandledViewpoint());
+ }
- @Override
- protected IContentProvider getContentProvider() {
- return new DiagramViewerContentProvider(page.getHandledViewpoint());
- }
+ @Override
+ protected void addListenersOnViewer(TreeViewer viewer) {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ /**
+ * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ public void doubleClick(DoubleClickEvent event_p) {
+ IStructuredSelection selection = (IStructuredSelection) event_p.getSelection();
+ // Open selected representations.
+ OpenRepresentationsAction action = new OpenRepresentationsAction();
+ action.selectionChanged(selection);
+ action.run();
+ }
+ });
+ }
- @Override
- protected void addListenersOnViewer(TreeViewer viewer) {
- viewer.addDoubleClickListener(new IDoubleClickListener() {
- /**
- * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- */
- public void doubleClick(DoubleClickEvent event_p) {
- IStructuredSelection selection = (IStructuredSelection) event_p.getSelection();
- // Open selected representations.
- OpenRepresentationsAction action = new OpenRepresentationsAction();
- action.selectionChanged(selection);
- action.run();
- }
- });
- }
+ @Override
+ public void dispose() {
+ super.dispose();
- @Override
- public void dispose() {
- super.dispose();
+ ISelectionProvider selectionProvider = page.getEditorSite().getSelectionProvider();
+ if (null != _renameRepresentationAction) {
+ selectionProvider.removeSelectionChangedListener(_renameRepresentationAction);
+ _renameRepresentationAction = null;
+ }
+ if (null != _deleteRepresentationAction) {
+ selectionProvider.removeSelectionChangedListener(_deleteRepresentationAction);
+ _deleteRepresentationAction = null;
+ }
+ if (null != _openRepresentation) {
+ selectionProvider.removeSelectionChangedListener(_openRepresentation);
+ _openRepresentation = null;
+ }
+ if (null != _moveDiagramAction) {
+ selectionProvider.removeSelectionChangedListener(_moveDiagramAction);
+ _moveDiagramAction.dispose();
+ _moveDiagramAction = null;
+ }
+ if (null != _cloneAction) {
+ selectionProvider.removeSelectionChangedListener(_cloneAction);
+ _cloneAction = null;
+ }
+ if (null != _showInModelExplorerAction) {
+ selectionProvider.removeSelectionChangedListener(_showInModelExplorerAction);
+ _showInModelExplorerAction = null;
+ }
- ISelectionProvider selectionProvider = page.getEditorSite().getSelectionProvider();
- if (null != _renameRepresentationAction) {
- selectionProvider.removeSelectionChangedListener(_renameRepresentationAction);
- _renameRepresentationAction = null;
- }
- if (null != _deleteRepresentationAction) {
- selectionProvider.removeSelectionChangedListener(_deleteRepresentationAction);
- _deleteRepresentationAction = null;
- }
- if (null != _openRepresentation) {
- selectionProvider.removeSelectionChangedListener(_openRepresentation);
- _openRepresentation = null;
- }
- if (null != _moveDiagramAction) {
- selectionProvider.removeSelectionChangedListener(_moveDiagramAction);
- _moveDiagramAction.dispose();
- _moveDiagramAction = null;
- }
- if (null != _cloneAction) {
- selectionProvider.removeSelectionChangedListener(_cloneAction);
- _cloneAction = null;
- }
- if (null != _showInModelExplorerAction) {
- selectionProvider.removeSelectionChangedListener(_showInModelExplorerAction);
- _showInModelExplorerAction = null;
- }
+ }
- }
+ /**
+ * Make a contextual menu for specified viewer.
+ * @param treeViewer_p
+ */
+ @Override
+ protected MenuManager initMenuToViewer(final TreeViewer treeViewer_p) {
+ MenuManager contextMenuManager = super.initMenuToViewer(treeViewer_p);
+ contextMenuManager.addMenuListener(new IMenuListener2() {
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("synthetic-access")
+ public void menuAboutToHide(IMenuManager manager_p) {
+ manager_p.remove(MoveRepresentationAction.MOVE_DIAGRAMS_MENU_ID);
+ // Make sure action contained list are freed at each selection
+ // time.
+ _moveDiagramAction.dispose();
+ }
- /**
- * Make a contextual menu for specified viewer.
- *
- * @param treeViewer_p
- */
- @Override
- protected MenuManager initMenuToViewer(final TreeViewer treeViewer_p) {
- MenuManager contextMenuManager = super.initMenuToViewer(treeViewer_p);
- contextMenuManager.addMenuListener(new IMenuListener2() {
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("synthetic-access")
- public void menuAboutToHide(IMenuManager manager_p) {
- manager_p.remove(MoveRepresentationAction.MOVE_DIAGRAMS_MENU_ID);
- // Make sure action contained list are freed at each selection
- // time.
- _moveDiagramAction.dispose();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("synthetic-access")
+ public void menuAboutToShow(IMenuManager manager_p) {
+ manager_p.appendToGroup(GROUP_MOVE, _moveDiagramAction.fillContextMenu((IStructuredSelection) treeViewer_p.getSelection()));
+ }
+ });
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("synthetic-access")
- public void menuAboutToShow(IMenuManager manager_p) {
- manager_p.appendToGroup(GROUP_MOVE,
- _moveDiagramAction.fillContextMenu((IStructuredSelection) treeViewer_p.getSelection()));
- }
- });
+ return contextMenuManager;
- return contextMenuManager;
+ }
- }
+ /**
+ * Declare viewer actions.<br>
+ * This methods is called eache time the menu is pop-up.
+ * @param contextMenuManager_p
+ * @param treeViewer_p
+ */
+ @Override
+ protected void declareViewerActions(MenuManager contextMenuManager_p, TreeViewer treeViewer_p) {
+ // Menu manager is not extensible at the moment.
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ ISelectionProvider selectionProvider = page.getEditorSite().getSelectionProvider();
- /**
- * Declare viewer actions.<br>
- * This methods is called eache time the menu is pop-up.
- *
- * @param contextMenuManager_p
- * @param treeViewer_p
- */
- protected void declareViewerActions(MenuManager contextMenuManager_p, TreeViewer treeViewer_p) {
- // Menu manager is not extensible at the moment.
- ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
- ISelectionProvider selectionProvider = page.getEditorSite().getSelectionProvider();
+ _showInModelExplorerAction = new BaseSelectionListenerAction(Messages.BasicSessionActivityExplorerPage_1) {
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void run() {
+ LocateInExplorerAction callback = new LocateInExplorerAction();
+ callback.setSite(page.getEditorSite());
+ callback.run(_showInModelExplorerAction);
+ }
- _showInModelExplorerAction = new BaseSelectionListenerAction(Messages.BasicSessionActivityExplorerPage_1) {
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("synthetic-access")
- @Override
- public void run() {
- LocateInExplorerAction callback = new LocateInExplorerAction();
- callback.setSite(page.getEditorSite());
- callback.run(_showInModelExplorerAction);
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection_p) {
+ return containsOnlyRepresentations(selection_p);
+ }
+ };
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean updateSelection(IStructuredSelection selection_p) {
- return containsOnlyRepresentations(selection_p);
- }
- };
+ SelectionHelper.registerToSelectionChanges(_showInModelExplorerAction, selectionProvider);
+ contextMenuManager_p.add(_showInModelExplorerAction);
- SelectionHelper.registerToSelectionChanges(_showInModelExplorerAction, selectionProvider);
- contextMenuManager_p.add(_showInModelExplorerAction);
+ contextMenuManager_p.add(new Separator());
+ _openRepresentation = new OpenRepresentationsAction() {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection_p) {
+ return containsOnlyRepresentations(selection_p);
+ }
+ };
+ SelectionHelper.registerToSelectionChanges(_openRepresentation, selectionProvider);
+ contextMenuManager_p.add(_openRepresentation);
+ contextMenuManager_p.add(new Separator());
- contextMenuManager_p.add(new Separator());
- _openRepresentation = new OpenRepresentationsAction() {
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean updateSelection(IStructuredSelection selection_p) {
- return containsOnlyRepresentations(selection_p);
- }
- };
- SelectionHelper.registerToSelectionChanges(_openRepresentation, selectionProvider);
- contextMenuManager_p.add(_openRepresentation);
- contextMenuManager_p.add(new Separator());
+ _cloneAction = new CloneAction(treeViewer_p);
+ _cloneAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ SelectionHelper.registerToSelectionChanges(_cloneAction, selectionProvider);
+ contextMenuManager_p.add(_cloneAction);
- _cloneAction = new CloneAction(treeViewer_p);
- _cloneAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- SelectionHelper.registerToSelectionChanges(_cloneAction, selectionProvider);
- contextMenuManager_p.add(_cloneAction);
+ _deleteRepresentationAction = new DeleteRepresentationAction() {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection_p) {
+ return containsOnlyRepresentations(selection_p);
+ }
+ };
+ _deleteRepresentationAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ _deleteRepresentationAction.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ SelectionHelper.registerToSelectionChanges(_deleteRepresentationAction, selectionProvider);
+ contextMenuManager_p.add(_deleteRepresentationAction);
- _deleteRepresentationAction = new DeleteRepresentationAction() {
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean updateSelection(IStructuredSelection selection_p) {
- return containsOnlyRepresentations(selection_p);
- }
- };
- _deleteRepresentationAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
- _deleteRepresentationAction.setDisabledImageDescriptor(sharedImages
- .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
- SelectionHelper.registerToSelectionChanges(_deleteRepresentationAction, selectionProvider);
- contextMenuManager_p.add(_deleteRepresentationAction);
+ contextMenuManager_p.add(new Separator(GROUP_MOVE));
+ _moveDiagramAction = new MoveRepresentationAction();
+ SelectionHelper.registerToSelectionChanges(_moveDiagramAction, selectionProvider);
+ _renameRepresentationAction = new RenameRepresentationAction() {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection_p) {
+ return containsOnlyRepresentations(selection_p);
+ }
+ };
+ SelectionHelper.registerToSelectionChanges(_renameRepresentationAction, selectionProvider);
+ contextMenuManager_p.add(_renameRepresentationAction);
+ }
- contextMenuManager_p.add(new Separator(GROUP_MOVE));
- _moveDiagramAction = new MoveRepresentationAction();
- SelectionHelper.registerToSelectionChanges(_moveDiagramAction, selectionProvider);
- _renameRepresentationAction = new RenameRepresentationAction() {
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean updateSelection(IStructuredSelection selection_p) {
- return containsOnlyRepresentations(selection_p);
- }
- };
- SelectionHelper.registerToSelectionChanges(_renameRepresentationAction, selectionProvider);
- contextMenuManager_p.add(_renameRepresentationAction);
- }
+ /**
+ * Returns <code>true</code> if specified selection contains only {@link DRepresentation}.
+ * @param selection_p
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ protected boolean containsOnlyRepresentations(final IStructuredSelection selection_p) {
+ boolean result = true;
+ Iterator<Object> iterator = selection_p.toList().iterator();
+ while (iterator.hasNext() && result) {
+ Object representation = iterator.next();
+ if (representation instanceof ItemWrapper) {
+ representation = ((ItemWrapper) representation).getWrappedObject();
+ }
+ if (!(representation instanceof DRepresentation)) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
- /**
- * Returns <code>true</code> if specified selection contains only
- * {@link DRepresentation}.
- *
- * @param selection_p
- * @return
- */
- @SuppressWarnings("unchecked")
- protected boolean containsOnlyRepresentations(final IStructuredSelection selection_p) {
- boolean result = true;
- Iterator<Object> iterator = selection_p.toList().iterator();
- while (iterator.hasNext() && result) {
- Object representation = iterator.next();
- if (representation instanceof ItemWrapper) {
- representation = ((ItemWrapper) representation).getWrappedObject();
- }
- if (!(representation instanceof DRepresentation)) {
- result = false;
- break;
- }
- }
- return result;
- }
+ /*************/
- /*************/
+ @Override
+ protected ViewerFilter getViewerFilter(final ActivityExplorerSection section) {
+ return new ViewerFilter() {
- protected ViewerFilter getViewerFilter(final ActivityExplorerSection section) {
- return new ViewerFilter() {
+ @Override
+ public boolean select(Viewer viewer_p, Object parentElement_p, Object element_p) {
+ boolean selected = true;
+ // Filter out viewpoint if any.
+ if (element_p instanceof ViewpointItem) {
+ ViewpointItem viewpointItem = (ViewpointItem) element_p;
+ Viewpoint viewpoint = (Viewpoint) viewpointItem.getWrappedObject();
+ if (viewpoint.getName().equals(getFilteredViewpoint())) {
+ selected = false;
+ }
+ }
+ // Filter representations.
+ else if (element_p instanceof RepresentationDescriptionItem) {
+ selected = isRepresentationDescriptionItemTypeSelected((RepresentationDescriptionItem) element_p, getRetainedRepresentationDescriptions());
+ }
+ // Filter diagrams.
+ else if (element_p instanceof DSemanticDiagram) {
+ DSemanticDiagram semanticDiagram = (DSemanticDiagram) element_p;
+ selected = isDiagramSelected(semanticDiagram.getTarget(), semanticDiagram.getDescription());
+ }
+ return selected;
+ }
- @Override
- public boolean select(Viewer viewer_p, Object parentElement_p, Object element_p) {
- boolean selected = true;
- // Filter out viewpoint if any.
- if (element_p instanceof ViewpointItem) {
- ViewpointItem viewpointItem = (ViewpointItem) element_p;
- Viewpoint viewpoint = (Viewpoint) viewpointItem.getWrappedObject();
- if (viewpoint.getName().equals(getFilteredViewpoint())) {
- selected = false;
- }
- }
- // Filter representations.
- else if (element_p instanceof RepresentationDescriptionItem) {
- selected = isRepresentationDescriptionItemTypeSelected((RepresentationDescriptionItem) element_p,
- getRetainedRepresentationDescriptions());
- }
- // Filter diagrams.
- else if (element_p instanceof DSemanticDiagram) {
- DSemanticDiagram semanticDiagram = (DSemanticDiagram) element_p;
- selected = isDiagramSelected(semanticDiagram.getTarget(), semanticDiagram.getDescription());
- }
- return selected;
- }
+ private Object getFilteredViewpoint() {
+ return null;
+ }
- private Object getFilteredViewpoint() {
- return null;
- }
+ protected Set<String> getRetainedRepresentationDescriptions() {
+ final Set<String> representations = new HashSet<String>();
+ for (ExplorerActivity activity : section.getActivities()) {
+ IHyperlinkListener listener = activity.getListener();
+ if (listener instanceof AbstractNewDiagramHyperlinkAdapter) {
+ representations.add(((AbstractNewDiagramHyperlinkAdapter) listener).getRepresentationName());
+ }
+ }
+ return representations;
+ }
- protected Set<String> getRetainedRepresentationDescriptions() {
- final Set<String> representations = new HashSet<String>();
- for (ExplorerActivity activity : section.getActivities()) {
- IHyperlinkListener listener = activity.getListener();
- if (listener instanceof AbstractNewDiagramHyperlinkAdapter)
- representations.add(((AbstractNewDiagramHyperlinkAdapter) listener).getRepresentationName());
- }
- return representations;
- }
+ protected boolean isDiagramSelected(EObject semanticElement_p, DiagramDescription diagramDescription_p) {
+ return true;
+ }
- protected boolean isDiagramSelected(EObject semanticElement_p, DiagramDescription diagramDescription_p) {
- return true;
- }
+ /**
+ * Is a {@link RepresentationDescriptionItem} selected ?
+ * @param representationDescriptionItem_p
+ * @return <code>true</code> means given <code>representationDescriptionItem_p</code> is selected i.e not filtered.
+ */
+ protected boolean isRepresentationDescriptionItemTypeSelected(RepresentationDescriptionItem representationDescriptionItem_p,
+ Set<String> retainedDiagramTypeNames_p) {
+ boolean selected = true;
+ if (retainedDiagramTypeNames_p != null) {
+ RepresentationDescription representationDescription = (RepresentationDescription) representationDescriptionItem_p.getWrappedObject();
+ String diagramTypeName = representationDescription.getName();
+ if (retainedDiagramTypeNames_p.contains(diagramTypeName)) {
+ selected = true;
+ } else {
+ selected = false;
+ }
+ }
+ return selected;
+ }
+ };
+ }
- /**
- * Is a {@link RepresentationDescriptionItem} selected ?
- *
- * @param representationDescriptionItem_p
- * @return <code>true</code> means given
- * <code>representationDescriptionItem_p</code> is selected
- * i.e not filtered.
- */
- protected boolean isRepresentationDescriptionItemTypeSelected(
- RepresentationDescriptionItem representationDescriptionItem_p,
- Set<String> retainedDiagramTypeNames_p) {
- boolean selected = true;
- if (retainedDiagramTypeNames_p != null) {
- RepresentationDescription representationDescription = (RepresentationDescription) representationDescriptionItem_p
- .getWrappedObject();
- String diagramTypeName = representationDescription.getName();
- if (retainedDiagramTypeNames_p.contains(diagramTypeName)) {
- selected = true;
- } else {
- selected = false;
- }
- }
- return selected;
- }
- };
- }
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java
index 45550cf..fe9c147 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java
@@ -32,106 +32,8 @@
*
*/
public class ActivityExplorerSessionListener implements SessionManagerListener {
- public WeakReference<Session> session = null;
- @Override
- public void notify(Session sessionp, int notification) {
- // Filter on event for other sessions.
- session = new WeakReference<Session>(sessionp);
- final ActivityExplorerEditor editor = ActivityExplorerManager.INSTANCE.getEditorFromSession(sessionp);
-
- Runnable runnable = null;
- switch (notification) {
- case SessionListener.CLOSING: /*
- * Closing event is used to have a chance to persist the editor input at workbench
- * shutdown
- */
-
- runnable = new Runnable() {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run() {
- if (editor != null)
- // Close this editor.
- editor.close(false);
- }
- };
- break;
- case SessionListener.REPRESENTATION_CHANGE:
- runnable = new Runnable() {
- /**
- * @see java.lang.Runnable#run()
- */
- @SuppressWarnings("synthetic-access")
- public void run() {
- // Handle fpages to mark them as dirty.
- if (editor != null) {
- IManagedForm headerForm = editor.getHeaderForm();
- if (null != headerForm) {
- headerForm.dirtyStateChanged();
- }
- }
- }
- };
- break;
-
- case SessionListener.OPENED:
- if (!(session.get().getSemanticResources().isEmpty())) {
- runnable = new Runnable() {
- @SuppressWarnings("synthetic-access")
- public void run() {
- try {
-
- final boolean open = ActivityExplorerActivator.getDefault().getPreferenceStore()
- .getBoolean(PreferenceConstants.P_OPEN_ACTIVITY_EXPLORER);
-
- if (open) {
-
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- activePage.openEditor(
- new ActivityExplorerEditorInput(session.get(),
- org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.SessionHelper
- .getRootSemanticModel(session.get())), ActivityExplorerEditor.ID);
- }
- }
- } catch (Exception exception) {
- StringBuilder loggerMessage = new StringBuilder(".run(..) _ ActivityExplorer not Found."); //$NON-NLS-1$
- loggerMessage.append(exception.getMessage());
- ActivityExplorerActivator.getDefault().sentToLogger(loggerMessage.toString(), IStatus.ERROR);
- // __logger.warn(new
- // EmbeddedMessage(loggerMessage.toString(),
- // IReportManagerDefaultComponents.UI),
- // exception);
- }
- }
- };
- }
- break;
- case SessionListener.DIRTY:
- case SessionListener.SYNC:
- case SessionListener.SEMANTIC_CHANGE: // Listening to changes to mark
- // the ActivityExplorerEditor editor dirty
- // hence saveable.
- runnable = new Runnable() {
- /**
- * {@inheritDoc}
- */
- public void run() {
- if (editor != null) {
- if (editor.getEditorInput() != null && !session.get().equals(editor.getEditorInput().getSession())) {
- return;
- }
- IManagedForm headerForm = editor.getHeaderForm();
- if (null != headerForm) {
- headerForm.dirtyStateChanged();
- }
- }
- }
- };
- break;
- }
+ protected void run(Runnable runnable) {
if (null != runnable) {
Display display = Display.getCurrent();
if (null == display) {
@@ -142,6 +44,165 @@
}
}
+ @Override
+ public void notify(Session sessionp, int notification) {
+
+ WeakReference<Session> session = new WeakReference<Session>(sessionp);
+
+ Runnable runnable = null;
+ switch (notification) {
+ case SessionListener.CLOSING:
+ notifyClosingSession(session);
+ break;
+ case SessionListener.REPRESENTATION_CHANGE:
+ notifyRepresentationChange(session);
+ break;
+ case SessionListener.OPENED:
+ notifyOpenedSession(session);
+ break;
+ case SessionListener.DIRTY:
+ case SessionListener.SYNC:
+ case SessionListener.SEMANTIC_CHANGE: // Listening to changes to mark
+ notifySemanticChange(session);
+ break;
+ case SessionListener.REPLACED:
+ notifyReplacedSession(session);
+ break;
+ }
+ run(runnable);
+
+ }
+
+ /**
+ * @param session
+ */
+ protected void notifyReplacedSession(WeakReference<Session> session) {
+ notifyRepresentationChange(session);
+ }
+
+ protected void notifySemanticChange(final WeakReference<Session> session2) {
+ // the ActivityExplorerEditor editor dirty
+ // hence saveable.
+ Runnable runnable = new Runnable() {
+
+ public void run() {
+ Session currentSession = session2.get();
+ if (currentSession != null) {
+ ActivityExplorerEditor editor = ActivityExplorerManager.INSTANCE.getEditorFromSession(currentSession);
+ if (editor == null) {
+ return;
+ }
+ if (editor.getEditorInput() == null) {
+ return;
+ }
+ if (!currentSession.equals(editor.getEditorInput().getSession())) {
+ return;
+ }
+ IManagedForm headerForm = editor.getHeaderForm();
+ if (null != headerForm) {
+ headerForm.dirtyStateChanged();
+ }
+ }
+ }
+ };
+ run(runnable);
+ }
+
+ protected void notifyOpenedSession(final WeakReference<Session> session2) {
+ if ((session2.get() != null) && !(session2.get().getSemanticResources().isEmpty())) {
+ Runnable runnable = new Runnable() {
+ @SuppressWarnings("synthetic-access")
+ public void run() {
+ try {
+ final boolean open = ActivityExplorerActivator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_OPEN_ACTIVITY_EXPLORER);
+ if (open) {
+
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (activePage != null) {
+ activePage.openEditor(new ActivityExplorerEditorInput(session2.get(),
+ org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.SessionHelper.getRootSemanticModel(session2.get())),
+ ActivityExplorerEditor.ID);
+ }
+ }
+ } catch (Exception exception) {
+ StringBuilder loggerMessage = new StringBuilder(".run(..) _ ActivityExplorer not Found."); //$NON-NLS-1$
+ loggerMessage.append(exception.getMessage());
+ ActivityExplorerActivator.getDefault().sentToLogger(loggerMessage.toString(), IStatus.ERROR);
+ // __logger.warn(new
+ // EmbeddedMessage(loggerMessage.toString(),
+ // IReportManagerDefaultComponents.UI),
+ // exception);
+ }
+ }
+ };
+ run(runnable);
+ }
+ }
+
+ protected void notifyRepresentationChange(final WeakReference<Session> session2) {
+
+ Runnable runnable = new Runnable() {
+
+ public void run() {
+ Session currentSession = session2.get();
+ if (currentSession != null) {
+ final ActivityExplorerEditor editor = ActivityExplorerManager.INSTANCE.getEditorFromSession(currentSession);
+ if (editor != null) {
+ // Handle fpages to mark them as dirty.
+ IManagedForm headerForm = editor.getHeaderForm();
+ if (null != headerForm) {
+ headerForm.dirtyStateChanged();
+ }
+ }
+ }
+
+ }
+ };
+ run(runnable);
+ }
+
+ /**
+ * Closing event is used to have a chance to persist the editor input at workbench shutdown
+ */
+ protected void notifyClosingSession(final WeakReference<Session> session2) {
+
+ Runnable runnable = new Runnable() {
+
+ public void run() {
+ Session currentSession = session2.get();
+ if (currentSession != null) {
+ final ActivityExplorerEditor editor = ActivityExplorerManager.INSTANCE.getEditorFromSession(currentSession);
+ if (editor != null) {
+ // Close this editor.
+ editor.close(false);
+ }
+ }
+ }
+ };
+ run(runnable);
+ }
+
+ /**
+ * Update the ActivityExplorer Editor.
+ * @param selectedViewpoint
+ */
+ protected void update(Viewpoint selectedViewpoint) {
+ final Session currentSession = SessionManager.INSTANCE.getSession(selectedViewpoint);
+
+ if ((selectedViewpoint != null) && (currentSession != null) && currentSession.isOpen()) {
+ Runnable refresh = new Runnable() {
+ @Override
+ public void run() {
+ ActivityExplorerEditor editor = ActivityExplorerManager.INSTANCE.getEditorFromSession(currentSession);
+ if (editor != null) {
+ editor.updateEditorPages(0);
+ }
+ }
+ };
+ run(refresh);
+ }
+ }
+
public void notifyAddSession(Session newSession) {
// Do nothing.
}
@@ -165,28 +226,4 @@
update(deselectedViewpoint);
}
- /**
- * Update the ActivityExplorer Editor.
- *
- * @param selectedViewpoint
- */
- private void update(Viewpoint selectedViewpoint) {
- final Session currentSession = SessionManager.INSTANCE.getSession(selectedViewpoint);
-
- if (selectedViewpoint != null && currentSession != null && currentSession.isOpen()) {
-
- Runnable refresh = new Runnable() {
-
- @Override
- public void run() {
- ActivityExplorerEditor editor = ActivityExplorerManager.INSTANCE.getEditorFromSession(currentSession);
- if (editor != null) {
- editor.updateEditorPages(0);
- }
- }
- };
- Display.getDefault().syncExec(refresh);
- }
- }
-
}