Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2009-10-02 16:24:18 +0000
committercdumoulin2009-10-02 16:24:18 +0000
commit32e3a191b6541f280b5f25deb138e3c6840f1216 (patch)
treef8c5ac8de9b14931050efbf0fafea09a5604dd41
parentfa52d426cb477c88c58cdfc2c549df7340965cfb (diff)
downloadorg.eclipse.papyrus-32e3a191b6541f280b5f25deb138e3c6840f1216.tar.gz
org.eclipse.papyrus-32e3a191b6541f280b5f25deb138e3c6840f1216.tar.xz
org.eclipse.papyrus-32e3a191b6541f280b5f25deb138e3c6840f1216.zip
ASSIGNED - bug 268775: [Sash Editor] Improve and finalize plugin
https://bugs.eclipse.org/bugs/show_bug.cgi?id=268775 Correct few problems after the merge.
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java3
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java89
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java24
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java11
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java2
-rw-r--r--plugins/developer/org.eclipse.papyrus.doc/templates/Papyrus Code Templates.xml32
-rw-r--r--plugins/others/org.eclipse.papyrus.sasheditor.ui/META-INF/MANIFEST.MF4
7 files changed, 121 insertions, 44 deletions
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java
index a8ebf992999..5cfd5cec079 100644
--- a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java
@@ -507,6 +507,9 @@ public class CoreMultiDiagramEditor extends /* MultiPageEditor */ AbstractMultiP
servicesRegistry.add(ActionBarContributorRegistry.class, 1, getActionBarContributorRegistry());
servicesRegistry.add(IEditorContextRegistry.class, 1, editorContextRegistry);
+ // Add EditingDomain as service
+ servicesRegistry.add(TransactionalEditingDomain.class, 1, defaultContext.getTransactionalEditingDomain());
+
// Create ContentProvider
PageModelFactory pageModelRegistry = new PageModelFactory(editorRegistry, servicesRegistry);
// TODO : create appropriate Resource for the contentProvider, and pass it here.
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java
index eeebfe13b13..c70ab5cf8bf 100644
--- a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java
@@ -5,20 +5,24 @@ package org.eclipse.papyrus.core.utils;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
import org.eclipse.papyrus.core.services.ServicesRegistry;
import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider;
import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr;
import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageMngr;
import org.eclipse.papyrus.sasheditor.contentprovider.di.TransactionalDiSashModelMngr;
+import org.eclipse.papyrus.sasheditor.editor.IPage;
+import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
/**
- * St of utility methods for the CoreEditor.
- * @author dumoulin
+ * Set of utility methods for the CoreEditor.
+ * @author cedric dumoulin
*/
public class EditorUtils {
@@ -70,23 +74,24 @@ public class EditorUtils {
* @return
* @throws IllegalStateException If there is no ActiveEditor (generally during editor initializing).
*/
- static private IEditorPart getWorkbenchActiveEditor() throws IllegalStateException {
+ static public IEditorPart getWorkbenchActiveEditor() throws IllegalStateException {
// Lookup ServiceRegistry
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(page==null)
- throw new IllegalStateException("No Active Page can be found. So no Service Registry can be returned.");
+ throw new IllegalStateException("No Active Page can be found.");
IEditorPart editorPart = page.getActiveEditor();
if(editorPart==null)
- throw new IllegalStateException("No Active Editor can be found. So no Service Registry can be returned.");
+ throw new IllegalStateException("No Active Editor can be found.");
if( ! (editorPart instanceof CoreMultiDiagramEditor) )
- throw new IllegalStateException("No CoreMultiDiagramEditor can be found. So no Service Registry can be returned.");
+ throw new IllegalStateException("No CoreMultiDiagramEditor can be found.");
return editorPart;
}
/**
- * Lookup the IPageMngr from the provided resource. Create it if not found.
+ * Create an instance of IPageMngr acting on the provided resource.
+ * This instance is suitable to add, remove, close or open diagrams.
* @param diResource
* @return The non transactional implementation of IPageMngr
*/
@@ -95,7 +100,8 @@ public class EditorUtils {
}
/**
- * Lookup the IPageMngr from the provided resource. Create it if not found.
+ * Create an instance of IPageMngr acting on the provided resource.
+ * This instance is suitable to add, remove, close or open diagrams.
* @param diResource
* @return The transactional implementation of IPageMngr
*/
@@ -104,4 +110,71 @@ public class EditorUtils {
}
+ /**
+ * Lookup the currently active Diagram from the Papyrus editor. Return the current Diagram
+ * or null if none is active.
+ * TODO This method introduce dependency on GMF. It can be moved to a GMF plugin.
+ * @return
+ */
+ public static Diagram lookupEditorActiveDiagram()
+ {
+ // First, lookup the main editor.
+ IEditorPart editorPart = getWorkbenchActiveEditor();
+ // Get the sashwindow container
+ ISashWindowsContainer container = (ISashWindowsContainer)editorPart.getAdapter(ISashWindowsContainer.class);
+
+ // Get the active page within the sashcontainer
+ IEditorPart activeEditor = container.getActiveEditor();
+ // Check if it is a GMF DiagramEditor
+ if( activeEditor instanceof DiagramEditor)
+ {
+ DiagramEditor editor = (DiagramEditor)activeEditor;
+ return editor.getDiagram();
+ }
+
+ // Not found
+ return null;
+
+ }
+
+ /**
+ * Lookup the currently active IEditor in the SashSystem.
+ * If the currently eclipse active editor doesn't contains a {@link ISashWindowsContainer}, return null.
+ * If the current SashSystem page is not a IEditor, return null.
+ * @return
+ */
+ public static IEditorPart lookupSashSystemActiveIEditor()
+ {
+ // First, lookup the main editor.
+ IEditorPart editorPart = getWorkbenchActiveEditor();
+ if(editorPart == null)
+ return null;
+ // Get the sashwindow container
+ ISashWindowsContainer container = (ISashWindowsContainer)editorPart.getAdapter(ISashWindowsContainer.class);
+ if( container == null)
+ return null;
+
+ // Get the active page within the sashcontainer
+ return container.getActiveEditor();
+ }
+ /**
+ * Lookup the currently active {@link IPage} in the SashSystem.
+ * If the currently eclipse active editor doesn't contains a {@link ISashWindowsContainer}, return null.
+ * If the current SashSystem page is not a IEditor, return null.
+ * @return
+ */
+ public static IPage lookupSashSystemActivePage()
+ {
+ // First, lookup the main editor.
+ IEditorPart editorPart = getWorkbenchActiveEditor();
+ if(editorPart == null)
+ return null;
+ // Get the sashwindow container
+ ISashWindowsContainer container = (ISashWindowsContainer)editorPart.getAdapter(ISashWindowsContainer.class);
+ if( container == null)
+ return null;
+
+ // Get the active page within the sashcontainer
+ return container.getActiveSashWindowsPage();
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java
index 5ad77406713..a3de64f176e 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java
@@ -179,6 +179,15 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
// Get the content provider if requested.
if (ISashWindowsContainer.class == adapter)
return sashContainer;
+
+ // Get the content provider if requested.
+ if (DeveloperDebug.class == adapter)
+ {
+ if( developerDebug == null)
+ developerDebug = new DeveloperDebug();
+
+ return developerDebug;
+ }
// Look in hierarchy
Object result = super.getAdapter(adapter);
@@ -210,4 +219,19 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
sashContainer.setFocus();
}
+
+ private DeveloperDebug developerDebug;
+ /**
+ * A hack to be able to print the internal structure of SashContainer.
+ * @author dumoulin
+ *
+ */
+ public class DeveloperDebug {
+ public void showSashWindowInfo() {
+ if(sashContainer instanceof SashWindowsContainer)
+ {
+ ((SashWindowsContainer)sashContainer).showTilesStatus();
+ }
+ }
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java
index bc03c9d7331..09ea8c6af08 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java
@@ -330,7 +330,7 @@ public class SashWindowsEventsProvider {
{
/**
- * Call the appropriate methid on the listener.
+ * Call the appropriate method on the listener.
* @see org.eclipse.papyrus.sasheditor.editor.SashWindowsEventsProvider.ListenersList#propertyChanged(java.lang.Object, java.lang.Object)
* @param listener
* @param newPage
@@ -338,7 +338,14 @@ public class SashWindowsEventsProvider {
*/
@Override
public void propertyChanged(IPageChangedListener listener, IPage newPage) {
- listener.pageChanged(newPage);
+
+ try {
+ listener.pageChanged(newPage);
+ } catch (Exception e) {
+ // catch error in case a listener send an exception.
+ // Still show the exception for debug purpose
+ e.printStackTrace();
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java
index edc34b6ee0a..51102da14e9 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java
@@ -359,7 +359,7 @@ public class SashWindowsContainer implements ISashWindowsContainer {
* Show the status of the different Tiles composing the sash system.
* Used for debug purpose.
*/
- protected void showTilesStatus()
+ public void showTilesStatus()
{
ShowPartStatusVisitor visitor = new ShowPartStatusVisitor();
rootPart.visit(visitor);
diff --git a/plugins/developer/org.eclipse.papyrus.doc/templates/Papyrus Code Templates.xml b/plugins/developer/org.eclipse.papyrus.doc/templates/Papyrus Code Templates.xml
index f382c8f3799..c40f19888d2 100644
--- a/plugins/developer/org.eclipse.papyrus.doc/templates/Papyrus Code Templates.xml
+++ b/plugins/developer/org.eclipse.papyrus.doc/templates/Papyrus Code Templates.xml
@@ -1,32 +1,4 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
- * @return the ${bare_field_name}
- */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**
- * @param ${param} the ${bare_field_name} to set
- */</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**
- * ${tags}
- */</template><template autoinsert="true" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**
- *
- */</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**
- * @author ${user}
- * ${tags}
- */</template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
- *
- */</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**
- * ${tags}
- */</template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/**
- * {@inheritDoc}
- */</template><template autoinsert="true" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="delegatecomment_context" deleted="true" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
* ${tags}
* ${see_to_target}
- */</template><template autoinsert="true" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">${filecomment}
-${package_declaration}
-
-${typecomment}
-${type_declaration}</template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classbody" name="classbody">
-</template><template autoinsert="true" context="interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name="interfacebody">
-</template><template autoinsert="true" context="enumbody_context" deleted="false" description="Code in new enum type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.enumbody" name="enumbody">
-</template><template autoinsert="true" context="annotationbody_context" deleted="false" description="Code in new annotation type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name="annotationbody">
-</template><template autoinsert="true" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock">// ${todo} Auto-generated catch block
-${exception_var}.printStackTrace();</template><template autoinsert="true" context="methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody">// ${todo} Auto-generated method stub
-${body_statement}</template><template autoinsert="true" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody">${body_statement}
-// ${todo} Auto-generated constructor stub</template><template autoinsert="true" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody">return ${field};</template><template autoinsert="true" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody">${field} = ${param};</template></templates> \ No newline at end of file
+ */</template></templates> \ No newline at end of file
diff --git a/plugins/others/org.eclipse.papyrus.sasheditor.ui/META-INF/MANIFEST.MF b/plugins/others/org.eclipse.papyrus.sasheditor.ui/META-INF/MANIFEST.MF
index 2b1c724ecc5..6750130f072 100644
--- a/plugins/others/org.eclipse.papyrus.sasheditor.ui/META-INF/MANIFEST.MF
+++ b/plugins/others/org.eclipse.papyrus.sasheditor.ui/META-INF/MANIFEST.MF
@@ -8,8 +8,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.papyrus.sasheditor;bundle-version="0.7.0",
org.eclipse.ui.forms;bundle-version="3.4.0",
- org.eclipse.jface.text;bundle-version="3.5.0",
- org.eclipse.gmf.runtime.notation;bundle-version="1.2.0",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.2.0"
+ org.eclipse.jface.text;bundle-version="3.5.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5

Back to the top