Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2009-02-18 15:56:44 +0000
committercdumoulin2009-02-18 15:56:44 +0000
commit2f0a2af5f07d8345a834da4bbaa97cf745aac1c2 (patch)
tree770874d5814e75dabff3b345a554a8a594979c45
parent6b2af078c817b52eaed0484c8dc787ece209a3bc (diff)
downloadorg.eclipse.papyrus-2f0a2af5f07d8345a834da4bbaa97cf745aac1c2.tar.gz
org.eclipse.papyrus-2f0a2af5f07d8345a834da4bbaa97cf745aac1c2.tar.xz
org.eclipse.papyrus-2f0a2af5f07d8345a834da4bbaa97cf745aac1c2.zip
Try to debug the ActionBarContributor.
-rw-r--r--org.eclipse.papyrus.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfComposedActionBarContributor.java324
-rw-r--r--org.eclipse.papyrus.core/plugin.xml19
-rw-r--r--org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/PapyrusActionBarContributor.java45
-rw-r--r--org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashDiagramModelManager.java13
-rw-r--r--org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashWindowModelManagerWrapper.java13
-rw-r--r--org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java27
-rw-r--r--org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/commands/RemoveTabFromFolderCommand.java65
-rw-r--r--org.eclipse.papyrus.di/plugin.xml2
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/eclipsecopy/ComposedActionBarContributor.java24
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/extension/MultiDiagramActionBarContributor.java2
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/gef/GefMultiPagesActionBarContributor.java5
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/ISashWindowsModelManager.java9
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/PTabFolder.java18
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/SashWindowsModelManagerImpl.java23
-rw-r--r--org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/TabFolderPart.java1
15 files changed, 185 insertions, 405 deletions
diff --git a/org.eclipse.papyrus.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfComposedActionBarContributor.java b/org.eclipse.papyrus.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfComposedActionBarContributor.java
deleted file mode 100644
index f409585d090..00000000000
--- a/org.eclipse.papyrus.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfComposedActionBarContributor.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/**
- *
- */
-package org.eclipse.papyrus.core.adaptor.gmf;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
-import org.eclipse.papyrus.di.presentation.DiActionBarContributor;
-import org.eclipse.papyrus.di.presentation.DiEditor;
-//import org.eclipse.papyrus.diagram.common.scribe.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
-import org.eclipse.papyrus.sasheditor.eclipsecopy.IMultiPageEditorActionBarContributor;
-import org.eclipse.papyrus.sasheditor.eclipsecopy.MultiPageEditorActionBarContributor;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.part.EditorActionBarContributor;
-
-
-/**
- *
- * An ActionBarContributor composed of ActionBarContributor from multi editor.
- * This ActionBarContributor switch to the contributor dedicated to the active editor in
- * a MultiPageEditor environement.
- *
- * @author dumoulin
- *
- */
-public class GmfComposedActionBarContributor extends MultiPageEditorActionBarContributor {
-
- /**
- * List of contributors.
- */
- protected ContributorMap<Class<? extends IEditorPart>, EditorActionBarContributor> contributors = new ContributorMap<Class<? extends IEditorPart>, EditorActionBarContributor>();
-
-
- /**
- * Contributor used as default.
- */
- protected EditorActionBarContributor defaultContributor;
-
- /**
- * The currently active contributor.
- */
- protected EditorActionBarContributor activeContributor;
-
-
- /**
- * Constructor.
- */
- public GmfComposedActionBarContributor() {
- // Init the contributors
- loadContributors();
- }
-
- /**
- * Sets the active page of the the multi-page editor to be the given editor.
- * Switch the currently active editor.
- * <p>
- * This method is called whenever the page changes. Subclasses must implement this method
- * to redirect actions to the given editor (if not already directed to it).
- * </p>
- *
- * @param activeEditor
- * the new active editor, or <code>null</code> if there is no active page, or if the
- * active page does not have a corresponding editor
- */
- @Override
- public void setActivePage(IEditorPart activeEditor)
- {
- // Check if we are already initialized
- // Return if we are not
- if(getPage()==null)
- return;
-
- activeContributor = getActionBarContributorFor(activeEditor);
- // Use default if none is found
- if(activeContributor == null)
- activeContributor = getDefaultActionBarContributor();
-
- System.out.println(this.getClass().getSimpleName()
- + ".setActivePage(" + activeEditor
- + ") :" + activeContributor );
-
- // Propagate call
- if(activeContributor instanceof IMultiPageEditorActionBarContributor)
- ((IMultiPageEditorActionBarContributor)activeContributor).setActivePage(activeEditor);
-
-
- }
-
- /**
- * Sets the active editor for the contributor.
- * <p>
- * The <code>EditorActionBarContributor</code> implementation of this method does
- * nothing. Subclasses may reimplement. This generally entails disconnecting
- * from the old editor, connecting to the new editor, and updating the actions
- * to reflect the new editor.
- * </p>
- *
- * @param targetEditor the new target editor
- */
- public void setActiveEditor(IEditorPart targetEditor) {
- // Switch the editor and activeContributor.
- super.setActiveEditor(targetEditor);
- // Now, propagate to the new activeContributor
- activeContributor.setActiveEditor(targetEditor);
- }
-
- /**
- * Lookup for the ActionBarContributor associated to the specified part.
- * @param activeEditor
- * @return
- */
- public EditorActionBarContributor getActionBarContributorFor(IEditorPart activeEditor) {
- Class<? extends IEditorPart> editorType = activeEditor.getClass();
-
-
- return contributors.get(editorType);
- }
-
- /**
- * Get an action bar by its type.
- * Return the action bar or null.
- * @param class1
- * @return
- */
- public EditorActionBarContributor getActionBarContributor(Class<? extends EditorActionBarContributor> type) {
- return contributors.getValueByItsClass(type);
- }
-
-
- /**
- * Get a default ActionBarContributor.
- * @return
- */
- private EditorActionBarContributor getDefaultActionBarContributor() {
- return defaultContributor;
- }
-
-
- private void loadContributors()
- {
- // default
- defaultContributor = new GmfUmlMultiDiagramActionBarContributor();
-// contributors.put( , defaultContributor);
-
- // scribe
-// EditorActionBarContributor contributor = new MultiPagesEditorActionBarContributor();
-// contributors.add( AbstractGraphicalPageWithFlyoutPalette.class, contributor);
-
- // GMF
- EditorActionBarContributor contributor = new UMLDiagramActionBarContributor();
- contributors.add( DiagramDocumentEditor.class, contributor);
-
- // emf
- contributor = new DiActionBarContributor();
- contributors.add( DiEditor.class, contributor);
-
- }
-
- // ************************************************ //
- // Propagate method calls //
- // ************************************************ //
-
- /**
- * Returns this contributor's action bars.
- *
- * @return the action bars
- */
- public IActionBars getActionBars() {
- return activeContributor.getActionBars();
- }
-
- /**
- * Dispose all the nested ActionBarContributors.
- */
- public void dispose() {
-
- // Dispose nested contributors.
- for(EditorActionBarContributor contributor : contributors.values() )
- {
- contributor.dispose();
- }
- }
-
- /**
- * The <code>EditorActionBarContributor</code> implementation of this
- * <code>IEditorActionBarContributor</code> method remembers the page
- * then forwards the call to <code>init(IActionBars)</code> for
- * backward compatibility
- */
- public void init(IActionBars bars, IWorkbenchPage page) {
- super.init(bars, page);
-
- System.out.println(this.getClass().getSimpleName() + ".init("+ bars+ ")");
- // init nested contributors.
- for(EditorActionBarContributor contributor : contributors.values() )
- {
- contributor.init(bars, page);
- }
- defaultContributor.init(bars, page);
-
- }
-
-
- /**
- * A light implementation of a map for contributors.
- * Map can't be used as we need to check inheritance for the key.
- * @author dumoulin
- *
- */
- protected class ContributorMap <K extends Class, V> {
-
- List<ContributorMapEntry<K, V>> entries = new ArrayList<ContributorMapEntry<K, V>>();
-
- /**
- * Add the specified value, associated with the key.
- * @param key
- * @param value
- */
- public void add( K key, V value )
- {
- if(indexOf(key) >=0)
- return;
-
- entries.add(new ContributorMapEntry<K, V>(key, value));
- }
-
- /**
- * Get the index of the entry containing the specified key.
- * @param key
- * @return
- */
- protected int indexOf( K key)
- {
- for(int i=0; i<entries.size(); i++)
- {
- ContributorMapEntry<K, V> entry = entries.get(i);
- if( entry.key.isInstance(key) )
- return i;
- }
- // not found
- return -1;
-
- }
- /**
- * Get a value by its key.
- * Check for subclasses.
- * @param key
- * @return
- */
- public V get( K key)
- {
- for(ContributorMapEntry<K, V> entry : entries)
- {
-
- if( entry.key.isAssignableFrom(key) )
- return entry.value;
- }
- // not found
- return null;
- }
-
- /**
- * Get a value by its class type.
- * Check for subclasses.
- * @param key
- * @return
- */
- public V getValueByItsClass( Class<? extends EditorActionBarContributor> type)
- {
- for(ContributorMapEntry<K, V> entry : entries)
- {
-
- if( type.isInstance(entry.value) )
- return entry.value;
- }
- // not found
- return null;
- }
-
- /**
- * Return a collection containing the values.
- * TODO: return a view instead of a copy
- * @return
- */
- public Collection<V> values()
- {
- List<V> res = new ArrayList<V>();
- for(ContributorMapEntry<K, V> entry : entries)
- {
- res.add(entry.value);
- }
- // not found
- return res;
-
- }
- }
-
- /**
- * A structure associating a contributor and a key.
- * Map can't be used as we need to check inheritance for the key.
- * @author dumoulin
- *
- */
- protected class ContributorMapEntry <K extends Class, T>{
- protected T value;
- protected K key;
- /**
- * @param key
- * @param value
- */
- public ContributorMapEntry(K key, T value) {
- this.key = key;
- this.value = value;
- }
-
- }
-
-}
diff --git a/org.eclipse.papyrus.core/plugin.xml b/org.eclipse.papyrus.core/plugin.xml
index 3d6a2b61dbf..523bc7cd7b8 100644
--- a/org.eclipse.papyrus.core/plugin.xml
+++ b/org.eclipse.papyrus.core/plugin.xml
@@ -4,25 +4,6 @@
<extension-point id="papyrusDiagram" name="PapyrusDiagram" schema="schema/papyrusDiagram.exsd"/>
<extension-point id="modelListener" name="ModelListener" schema="schema/modelListener.exsd"/>
<extension-point id="papyrusContentOutline" name="PapyrusContentOutline" schema="schema/contentOutline.exsd"/>
- <extension point="org.eclipse.ui.editors">
- <editor
- class="org.eclipse.papyrus.core.editor.SashMultiDiagramEditor"
- contributorClass="org.eclipse.papyrus.core.editor.PapyrusActionBarContributor"
- default="false"
- extensions="di2"
- icon="icons/papyrus/Papyrus.gif"
- id="org.eclipse.papyrus.core.papyrusEditor"
- name="Papyrus Editor Core">
- </editor>
- </extension>
- <extension point="org.eclipse.ui.perspectives">
- <perspective
- class="org.eclipse.papyrus.core.perspective.PapyrusPerspective"
- icon="icons/papyrus/Papyrus.gif"
- id="org.eclipse.papyrus.core.perspective"
- name="Papyrus">
- </perspective>
- </extension>
</plugin>
diff --git a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/PapyrusActionBarContributor.java b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/PapyrusActionBarContributor.java
deleted file mode 100644
index d39fb6f779e..00000000000
--- a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/PapyrusActionBarContributor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- */
-package org.eclipse.papyrus.core.editor;
-
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.CoreComposedActionBarContributor;
-import org.eclipse.ui.IEditorActionBarContributor;
-
-
-/**
- * EditorActionBarContributor suitable to Papyrus multi editor.
- * This ActionBarContributor is composed of ActionBarContributor described in extension.
- * It also implements interfaces requested by some well knowns Papyrus nested
- * editors (EMF, GMF, ...)
- *
- * @author dumoulin
- *
- */
-public class PapyrusActionBarContributor extends CoreComposedActionBarContributor implements IMenuListener {
-
-
- public PapyrusActionBarContributor() throws BackboneException {
- super();
- }
-
- /**
- * Methods requested by EMF nested diagrams.
- * Propagate the call to the currently active contributor.
- * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- * @param manager
- *
- */
- public void menuAboutToShow(IMenuManager manager) {
- IEditorActionBarContributor contributor = getActiveContributor();
- if(contributor != this && contributor instanceof IMenuListener)
- {
- ((IMenuListener) contributor).menuAboutToShow(manager);
- return;
- }
-
- }
-
-}
diff --git a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashDiagramModelManager.java b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashDiagramModelManager.java
index c799e9504f3..233cd7f8c2f 100644
--- a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashDiagramModelManager.java
+++ b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashDiagramModelManager.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.core.multidiagram.commands.MoveTabFromFolderToFolderCommand;
import org.eclipse.papyrus.core.multidiagram.commands.MoveTabInsideFolderCommand;
import org.eclipse.papyrus.core.multidiagram.commands.MoveTabToFolderSideCommand;
+import org.eclipse.papyrus.core.multidiagram.commands.RemoveTabFromFolderCommand;
import org.eclipse.papyrus.di.Diagram;
/**
@@ -151,4 +152,16 @@ public class SashDiagramModelManager extends SashDiagramModelUtil {
editingDomain.getCommandStack().execute(command);
}
+ /**
+ * Remove the specified tab from the specified folder.
+ * @param srcFolder
+ * @param srcIndex
+ */
+ public void doRemoveTab(Diagram srcFolder, int srcIndex) {
+ TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
+ RecordingCommand command = new RemoveTabFromFolderCommand(editingDomain, srcFolder, srcIndex);
+
+ editingDomain.getCommandStack().execute(command);
+ }
+
}
diff --git a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashWindowModelManagerWrapper.java b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashWindowModelManagerWrapper.java
index e27d2376078..88c30ab4fcf 100644
--- a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashWindowModelManagerWrapper.java
+++ b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/SashWindowModelManagerWrapper.java
@@ -135,6 +135,18 @@ public class SashWindowModelManagerWrapper extends SashWindowsModelManagerImpl<D
}
/**
+ * Remove the specified tab from the folder.
+ * Also remove the tab if it is empty.
+ * @see org.eclipse.papyrus.sasheditor.sash.ISashWindowsModelManager#removeTab(org.eclipse.papyrus.sasheditor.sash.TabFolderPart.ITabFolderModel, int)
+ * @param srcFolder
+ * @param srcIndex
+ *
+ */
+ public void removeTab(Diagram srcFolder, int srcIndex) {
+ diagramModelManager.doRemoveTab((Diagram) srcFolder, srcIndex);
+ }
+
+ /**
* @see org.eclipse.papyrus.sasheditor.sash.SashWindowsModelManagerImpl#moveTab(java.lang.Object, int, int)
*/
@Override
@@ -359,4 +371,5 @@ public class SashWindowModelManagerWrapper extends SashWindowsModelManagerImpl<D
}
}
+
}
diff --git a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java
index 11232940445..f64479deae1 100644
--- a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java
+++ b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java
@@ -5,10 +5,13 @@ package org.eclipse.papyrus.core.multidiagram.actionbarcontributor;
import java.util.List;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
import org.eclipse.papyrus.core.Activator;
import org.eclipse.papyrus.core.editor.BackboneException;
import org.eclipse.papyrus.sasheditor.eclipsecopy.ComposedActionBarContributor;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.part.EditorActionBarContributor;
@@ -39,7 +42,10 @@ public class CoreComposedActionBarContributor extends ComposedActionBarContribut
loadContributors();
}
-
+ /**
+ *
+ * @throws BackboneException
+ */
private void loadContributors() throws BackboneException
{
actionBarContributorRegistry = new ActionBarContributorRegistry(Activator.PLUGIN_ID);
@@ -61,11 +67,13 @@ public class CoreComposedActionBarContributor extends ComposedActionBarContribut
*/
public void dispose() {
+ System.err.println("ActionBarContributor.dispose()" + this);
// Dispose nested contributors.
for(EditorActionBarContributor contributor : contributors )
{
contributor.dispose();
}
+ super.dispose();
}
/**
@@ -76,7 +84,9 @@ public class CoreComposedActionBarContributor extends ComposedActionBarContribut
*/
public void init(IActionBars bars, IWorkbenchPage page) {
+ System.err.println("ActionBarContributor.init() - " + this);
super.init(bars, page);
+ buildActions();
System.out.println(this.getClass().getSimpleName() + ".init("+ bars+ ")");
// init nested contributors.
@@ -88,6 +98,21 @@ public class CoreComposedActionBarContributor extends ComposedActionBarContribut
}
+ /**
+ * Load default actions (undo/redo/delete)
+ *
+ * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions()
+ */
+ protected void buildActions() {
+ getActionBars().getToolBarManager().add( new UndoRetargetAction() );
+ getActionBars().getToolBarManager().add(new RedoRetargetAction());
+ }
+
+
+ public void setActiveEditor(IEditorPart targetEditor) {
+ System.err.println("ActionBarContributor.setActiveEditor(" + targetEditor + ") - " + this);
+ super.setActiveEditor(targetEditor);
+ }
}
diff --git a/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/commands/RemoveTabFromFolderCommand.java b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/commands/RemoveTabFromFolderCommand.java
new file mode 100644
index 00000000000..ccfbcd527b2
--- /dev/null
+++ b/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/commands/RemoveTabFromFolderCommand.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.core.multidiagram.commands;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.di.Diagram;
+
+/**
+ * Move a tab inside the same folder.
+ *
+ */
+public class RemoveTabFromFolderCommand extends RecordingCommand {
+
+ Diagram srcfolder;
+
+ int srcTabIndex;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param domain
+ * @param srcfolder
+ * folder into which a tab is moved
+ * @param srcTabIndex
+ * index of the tab to move
+ * @param targetTabIndex
+ * new index of the tab after the move.
+ */
+ public RemoveTabFromFolderCommand(TransactionalEditingDomain domain, Diagram srcfolder, int srcTabIndex) {
+ super(domain);
+ this.srcfolder = srcfolder;
+ this.srcTabIndex = srcTabIndex;
+ }
+
+ /**
+ * Execute the command.
+ *
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ */
+ protected void doExecute() {
+
+ if (srcTabIndex <0 || srcTabIndex >= srcfolder.getContained().size())
+ {
+ return;
+ }
+
+ srcfolder.getContained().remove(srcTabIndex);
+
+ }
+
+}
diff --git a/org.eclipse.papyrus.di/plugin.xml b/org.eclipse.papyrus.di/plugin.xml
index d0379a49321..3029f560a97 100644
--- a/org.eclipse.papyrus.di/plugin.xml
+++ b/org.eclipse.papyrus.di/plugin.xml
@@ -13,7 +13,7 @@
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://www.eclipse.org/papyrus/0.7.0/di"
- class = "org.eclipse.papyrus.di.Di2Package"
+ class = "org.eclipse.papyrus.di.DiPackage"
genModel = "model/di2.genmodel" />
</extension>
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/eclipsecopy/ComposedActionBarContributor.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/eclipsecopy/ComposedActionBarContributor.java
index a773cdb44b9..44e685fbfd3 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/eclipsecopy/ComposedActionBarContributor.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/eclipsecopy/ComposedActionBarContributor.java
@@ -71,6 +71,10 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri
if(getPage()==null)
return;
+ // skip if the activeEditor doesn't change.
+ if(activeEditor == activeNestedEditor)
+ return;
+
if(log.isLoggable(Level.FINE))
{
log.fine("setActivePage("+ activeEditor + " "+")" );
@@ -78,9 +82,9 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri
activeNestedEditor = activeEditor;
- System.out.println(this.getClass().getSimpleName()
- + ".setActivePage(" + activeEditor
- + ") :" + activeNestedEditor.getEditorSite().getActionBarContributor() );
+// System.out.println(this.getClass().getSimpleName()
+// + ".setActivePage(" + activeEditor
+// + ") :" + getActiveContributor() );
// Propagate call if possible
// Call setActiveEditor() on nested contributor.
@@ -144,13 +148,13 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri
*
* @return the action bars
*/
- public IActionBars getActionBars() {
- IEditorActionBarContributor activeContributor = getActiveContributor();
- if( activeContributor!=this && activeContributor instanceof EditorActionBarContributor)
- return ((EditorActionBarContributor)getActiveContributor()).getActionBars();
- else
- return super.getActionBars();
- }
+// public IActionBars getActionBars() {
+// IEditorActionBarContributor activeContributor = getActiveContributor();
+// if( activeContributor!=this && activeContributor instanceof EditorActionBarContributor)
+// return ((EditorActionBarContributor)getActiveContributor()).getActionBars();
+// else
+// return super.getActionBars();
+// }
}
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/extension/MultiDiagramActionBarContributor.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/extension/MultiDiagramActionBarContributor.java
index c6331fb1519..b6dff342623 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/extension/MultiDiagramActionBarContributor.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/extension/MultiDiagramActionBarContributor.java
@@ -44,7 +44,7 @@ public abstract class MultiDiagramActionBarContributor extends GefMultiPagesActi
* @return the EditorRegistry for nested editor descriptors.
* TODO Seem to be unused. Remove ?
*/
- abstract protected EditorFactoryRegistry getEditorRegistry();
+// abstract protected EditorFactoryRegistry getEditorRegistry();
/**
* Add retarget actions to the given toolbar.
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/gef/GefMultiPagesActionBarContributor.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/gef/GefMultiPagesActionBarContributor.java
index 9f2c5cdfac0..062daa4aae8 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/gef/GefMultiPagesActionBarContributor.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/gef/GefMultiPagesActionBarContributor.java
@@ -26,10 +26,9 @@ import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.part.EditorActionBarContributor;
-//import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
/**
- * This class is an attempt to merge gef ActionBarContributor and MultiPagesActionBarContributor
+ * This class is an attempt to merge gef ActionBarContributor and MultiPagesActionBarContributor.
*/
public abstract class GefMultiPagesActionBarContributor extends MultiPageEditorActionBarContributor {
@@ -189,10 +188,12 @@ public abstract class GefMultiPagesActionBarContributor extends MultiPageEditorA
* Connect the actions registered in the globalActionKeys. Lookup actions implementation in the rootEditor registry and in the current page registry.
*/
protected void connectActions() {
+ System.out.println("scribe.connectActions()");
IActionBars bars = getActionBars();
Iterator<String> iter = globalActionKeys.iterator();
while (iter.hasNext()) {
String id = iter.next();
+ System.out.println("connect(" + id + ", " + getEditorAction(id) + ")" );
bars.setGlobalActionHandler(id, getEditorAction(id));
bars.updateActionBars();
}
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/ISashWindowsModelManager.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/ISashWindowsModelManager.java
index 12c3970fe6a..d4d90d1f90d 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/ISashWindowsModelManager.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/ISashWindowsModelManager.java
@@ -52,6 +52,15 @@ public interface ISashWindowsModelManager <T> {
*/
public ITilePart.ITilePartNodeModel<T> createTilePartModel(T model);
+
+ /**
+ * Remove the specified tab from the specified folder.
+ * Remove the folder if it is empty.
+ * @param srcFolder
+ * @param srcIndex
+ */
+ public void removeTab(ITabFolderModel<T> srcFolder, int srcIndex);
+
/**
* Ask the model to move the specified tab inside the same folder. No events should be thrown until the complete move is perform. This method is called by the the SashTileContainer when the user
* have drag a tab in a correct place. The SashTileContainer has not change is presentation yet. This will be done when the corresponding event will occur.
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/PTabFolder.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/PTabFolder.java
index 953ed3c96b7..9d82fd4ec28 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/PTabFolder.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/PTabFolder.java
@@ -81,6 +81,14 @@ public class PTabFolder {
}
};
+ private Listener mouseUpListener = new Listener() {
+
+ public void handleEvent(Event e) {
+ Point globalPos = ((Control) e.widget).toDisplay(e.x, e.y);
+ System.out.println("mouseUpListener(" + globalPos + ", event=" + e + ")");
+ }
+ };
+
// private DragDetectListener dragDetectListener = new DragDetectListener() {
//
// public void dragDetected(DragDetectEvent e) {
@@ -130,6 +138,8 @@ public class PTabFolder {
// inside the folder
parent.setLayout(new FillLayout());
final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT | SWT.CLOSE);
+
+ // TODO Move listener init in appropriate method.
newContainer.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -138,10 +148,9 @@ public class PTabFolder {
}
});
- // TODO Remove next
// Test for the close icon. Need style=SWT.CLOSE
// addCTabFolderListener is required :-(
- newContainer.setUnselectedCloseVisible(true);
+ newContainer.setUnselectedCloseVisible(false);
newContainer.addCTabFolder2Listener(new CTabFolder2Adapter() {
@Override
@@ -178,6 +187,7 @@ public class PTabFolder {
// theControl.addDragDetectListener(dragDetectListener);
// Listen on mouse enter event.
// theControl.addListener(SWT.MouseEnter, mouseEnterListener);
+ theControl.addListener(SWT.MouseUp, mouseUpListener);
if (recursive && theControl instanceof Composite) {
Composite composite = (Composite) theControl;
@@ -200,6 +210,7 @@ public class PTabFolder {
//
PresentationUtil.removeDragListener(theControl, dragListener);
// theControl.removeDragDetectListener(dragDetectListener);
+ theControl.removeListener(SWT.MouseUp, mouseUpListener);
if (recursive && theControl instanceof Composite) {
Composite composite = (Composite) theControl;
@@ -449,6 +460,9 @@ public class PTabFolder {
*
*/
public class EventsManager {
+ /**
+ * List of event listeners.
+ */
List<IPTabFolderListener> listeners = new ArrayList<IPTabFolderListener>();
/**
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/SashWindowsModelManagerImpl.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/SashWindowsModelManagerImpl.java
index 3c84e0a3e3f..087ce2b8c72 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/SashWindowsModelManagerImpl.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/SashWindowsModelManagerImpl.java
@@ -96,6 +96,18 @@ public abstract class SashWindowsModelManagerImpl<T> implements ISashWindowsMode
abstract public void createFolder(Object nodeModel, int srcTabIndex, Object nodeModel2, int side);
/**
+ * Remove the specified tab from the folder.
+ * Also remove the tab if it is empty.
+ * @see org.eclipse.papyrus.sasheditor.sash.ISashWindowsModelManager#removeTab(org.eclipse.papyrus.sasheditor.sash.TabFolderPart.ITabFolderModel, int)
+ * @param srcFolder
+ * @param srcIndex
+ *
+ */
+ public void removeTab(ITabFolderModel<T> srcFolder, int srcIndex) {
+ removeTab(srcFolder.getNodeModel(), srcIndex );
+ }
+
+ /**
* @see org.eclipse.papyrus.sasheditor.sash.ISashWindowsModelManager#moveTab(org.eclipse.papyrus.sasheditor.sash.TabFolderPart.ITabFolderModel, int, int)
*/
public void moveTab(ITabFolderModel<T> srcFolder, int srcIndex, int targetIndex) {
@@ -104,6 +116,17 @@ public abstract class SashWindowsModelManagerImpl<T> implements ISashWindowsMode
}
/**
+ * Ask the model to remove the specified tab inside the same folder. No events
+ * should be thrown until the complete remove is perform. This method is called by
+ * the the SashTileContainer when the user click the close cross on a tab.. The
+ * SashTileContainer has not change is presentation yet. This will be done when the
+ * corresponding event will occur.
+ * @param nodeModel The external model representing a folder.
+ * @param srcIndex
+ */
+ abstract public void removeTab(T nodeModel, int srcIndex);
+
+ /**
* Ask the model to move the specified tab inside the same folder. No events should be thrown until the complete move is perform. This method is called by the the SashTileContainer when the user
* have drag a tab in a correct place. The SashTileContainer has not change is presentation yet. This will be done when the corresponding event will occur.
* @param nodeModel The external model representing a folder.
diff --git a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/TabFolderPart.java b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/TabFolderPart.java
index d779ae91e29..f20be91c795 100644
--- a/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/TabFolderPart.java
+++ b/org.eclipse.papyrus.sasheditor/src/org/eclipse/papyrus/sasheditor/sash/TabFolderPart.java
@@ -112,6 +112,7 @@ public class TabFolderPart<T> extends MultiPageEditorTile implements ITilePart<T
public void itemClosedEvent(CTabFolderEvent event, int pageIndex) {
System.out.println("itemClosedEvent()");
+ parentPartContainer.getContainerModel().removeTab(model, pageIndex);
}
public void menuDetectEvent(CTabItem tab, MenuDetectEvent event) {

Back to the top