Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2015-10-27 12:40:59 +0000
committerEsteban DUGUEPEROUX2015-11-02 07:55:16 +0000
commit366827e38895db0dcc2f20c694a07417b5ed509e (patch)
treebe2c2d3922d501bbdc6709ef30829270364d7a7b
parentfa4e815458cba3e83ef69c1f80af9d94863cdd8e (diff)
downloadorg.eclipse.sirius-366827e38895db0dcc2f20c694a07417b5ed509e.tar.gz
org.eclipse.sirius-366827e38895db0dcc2f20c694a07417b5ed509e.tar.xz
org.eclipse.sirius-366827e38895db0dcc2f20c694a07417b5ed509e.zip
[480773] Manage better editor opening on Eclipse restart
- Manage better editor opening on Eclipse restart with failing session opening. Bug: 480773 Change-Id: I36a54c171eab3fc63c704dd4590780657cf18150 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/plugin.properties1
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java9
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusMarkerNavigationProvider.java9
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramEditor.java7
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java262
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java36
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/Tabbar.java36
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/part/SiriusDiagramGraphicalViewer.java15
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewAction.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewHelper.java16
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusEnhancedPrintActionHelper.java28
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/filters/FiltersTableViewer.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersTableViewer.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java3
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html26
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile6
-rw-r--r--plugins/org.eclipse.sirius.table.ui/plugin.properties1
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src-gen/org/eclipse/sirius/table/metamodel/table/provider/Messages.java3
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/AbstractDTableEditor.java40
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableActionBarContributor.java57
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/plugin.properties4
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java1
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/provider/Messages.java6
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeActionBarContributor.java8
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeEditor.java45
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java46
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInputFactory.java13
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java39
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/UndoRedoActionHandler.java2
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java60
-rw-r--r--plugins/org.eclipse.sirius/plugin.properties2
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/SessionManagerImpl.java4
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java19
33 files changed, 513 insertions, 297 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.properties b/plugins/org.eclipse.sirius.diagram.ui/plugin.properties
index 35b93e7f8e..1ef73d6f88 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/plugin.properties
+++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.properties
@@ -814,6 +814,7 @@ CustomTreeSelectionDialog_regexpTitle = Filter elements by name
CustomTreeSelectionDialog_regexpTooltip = Expression that will be used to filer elements by name (for example 'abc', 'a?c', '*c'...)
CustomTreeSelectionDialog_showLabelText = Show
CustomTreeSelectionDialog_uncheckAllButtonTooltip = Uncheck All
+DDiagramEditorImpl_editorToBeClosedAndReopenedSinceContentIsNotAccessible={0}\nContent access has failed at editor opening, you can try to reopen this editor.
DDiagramEditorImpl_cdoServerConnectionPbMsg = Error while connecting to remote CDO server
DDiagramEditorImpl_noAssociatedGMFDiagramMsg = The gmf diagram is expected to be created before calling setInput() on the editor
DDiagramEditorImpl_noSessionMsg = Error while getting the session.
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
index 86c8d2a5a1..abfffd8b7d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
@@ -298,7 +298,10 @@ public class DiagramDialectUIServices implements DialectUIServices {
boolean result = false;
if (editorPart instanceof DiagramDocumentEditor) {
try {
- ((DiagramDocumentEditor) editorPart).getDiagramEditPart().deactivate();
+ DiagramEditPart diagramEditPart = ((DiagramDocumentEditor) editorPart).getDiagramEditPart();
+ if (diagramEditPart != null) {
+ diagramEditPart.deactivate();
+ }
} catch (final NullPointerException e) {
// we might have an exception closing an editor which is
// already in trouble
@@ -310,9 +313,7 @@ public class DiagramDialectUIServices implements DialectUIServices {
} catch (final NullPointerException e) {
// we might have an exception closing an editor which is
// already in trouble
- if (DiagramUIPlugin.getPlugin().isDebugging()) {
- DiagramUIPlugin.getPlugin().getLog().log(new Status(IStatus.WARNING, DiagramUIPlugin.ID, Messages.DiagramDialectUIServices_diagramEditorClosingError));
- }
+ DiagramUIPlugin.getPlugin().getLog().log(new Status(IStatus.WARNING, DiagramUIPlugin.ID, Messages.DiagramDialectUIServices_diagramEditorClosingError, e));
}
// We suppose it is closed.
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusMarkerNavigationProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusMarkerNavigationProvider.java
index b58d73a0c4..946bbf1944 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusMarkerNavigationProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusMarkerNavigationProvider.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.emf.ui.providers.marker.AbstractModelMarkerNavigationProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.sirius.diagram.DiagramPlugin;
import org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditorUtil;
import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin;
@@ -49,8 +50,12 @@ public class SiriusMarkerNavigationProvider extends AbstractModelMarkerNavigatio
return;
}
DiagramEditor editor = (DiagramEditor) getEditor();
- Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
- EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
+ Map<?, ?> editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
+ Diagram diagram = editor.getDiagram();
+ if (diagram == null) {
+ return;
+ }
+ EObject targetView = diagram.eResource().getEObject(elementId);
if (targetView == null) {
return;
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramEditor.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramEditor.java
index 9ae3f7531f..dc6ce17346 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramEditor.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others.
* 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
@@ -101,6 +101,7 @@ public class SiriusDiagramEditor extends DiagramDocumentEditor implements IGotoM
if (type == IShowInTargetList.class) {
return new IShowInTargetList() {
+ @Override
public String[] getShowInTargetIds() {
return new String[] { ProjectExplorer.VIEW_ID, IModelExplorerView.ID };
}
@@ -128,6 +129,7 @@ public class SiriusDiagramEditor extends DiagramDocumentEditor implements IGotoM
/**
* @was-generated
*/
+ @Override
public void gotoMarker(final IMarker marker) {
MarkerNavigationService.getInstance().gotoMarker(this, marker);
}
@@ -141,6 +143,7 @@ public class SiriusDiagramEditor extends DiagramDocumentEditor implements IGotoM
*
* @return the workspace viewer <code>PreferenceStore</code>
*/
+ @Override
public PreferenceStore getWorkspaceViewerPreferenceStore() {
if (workspaceViewerPreferenceStore != null) {
return workspaceViewerPreferenceStore;
@@ -206,7 +209,7 @@ public class SiriusDiagramEditor extends DiagramDocumentEditor implements IGotoM
private ISelection getNavigatorSelection() {
if (getEditorInput() instanceof SessionEditorInput) {
SessionEditorInput sessionEditorInput = (SessionEditorInput) getEditorInput();
- Session session = sessionEditorInput.getSession();
+ Session session = sessionEditorInput.getSession(false);
if (session != null) {
Resource sessionResource = session.getSessionResource();
if (sessionResource != null && sessionResource.getURI().isPlatformResource()) {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java
index 0a182eb645..34edc96ade 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.internal.editor;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,6 +30,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
@@ -47,12 +50,15 @@ import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.KeyHandler;
import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.MouseWheelHandler;
import org.eclipse.gef.MouseWheelZoomHandler;
import org.eclipse.gef.Request;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.dnd.AbstractTransferDropTargetListener;
import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
+import org.eclipse.gef.editparts.LayerManager;
import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.ui.actions.ActionRegistry;
@@ -68,6 +74,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
@@ -78,6 +85,7 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.AbstractInformationControlManager;
import org.eclipse.jface.text.IDocument;
@@ -413,18 +421,18 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
this.session = ((SessionEditorInput) correctedInput).getSession();
}
- final Collection<Session> sessions = SessionManager.INSTANCE.getSessions();
-
- /*
- * we are during eclipse boot, we are not trying to close the editor
- */
- if (sessions.isEmpty() && (!isClosing)) {
- SessionManager.INSTANCE.addSessionsListener(sessionManagerListener);
- }
- isClosing = false;
-
try {
if (getSession() != null) {
+ /*
+ * we are during eclipse boot, we are not trying to close the
+ * editor
+ */
+ Collection<Session> sessions = SessionManager.INSTANCE.getSessions();
+ if (sessions.isEmpty() && (!isClosing)) {
+ SessionManager.INSTANCE.addSessionsListener(sessionManagerListener);
+ }
+ isClosing = false;
+
// Initialize the undo context
initUndoContext();
// Enable GMF notation model canonical refresh in pre-commit
@@ -487,27 +495,33 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
-
- // Initialize drag'n drop listener from palette
- // PaletteViewer paletteViewer =
- // getPaletteViewerProvider().getEditDomain().getPaletteViewer();
- // paletteTransferDragSourceListener = new
- // TemplateTransferDragSourceListener(paletteViewer);
- // paletteViewer.addDragSourceListener(paletteTransferDragSourceListener);
- //
- // paletteTransferDropTargetListener = new
- // ViewpointPaletteToolDropTargetListener(getGraphicalViewer());
- // getDiagramGraphicalViewer().addDropTargetListener(paletteTransferDropTargetListener);
-
- tabbarPostCommitListener = new TabbarRefresher(getEditingDomain());
- visibilityPostCommitListener = new VisibilityPostCommitListener(getDiagramEditPart());
- if (isHeaderSectionEnabled()) {
- diagramHeaderPostCommitListener = new DiagramHeaderPostCommitListener(getEditingDomain(), getDiagramHeader());
+ // Display the status message to inform user about reason why the
+ // session opening failed
+ if (session == null && getEditorInput() instanceof SessionEditorInput) {
+ SessionEditorInput sessionEditorInput = (SessionEditorInput) getEditorInput();
+ IStatus status = sessionEditorInput.getStatus();
+ if (status.getSeverity() >= IStatus.ERROR) {
+ RootEditPart rootEditPart = getGraphicalViewer().getRootEditPart();
+ if (rootEditPart instanceof LayerManager) {
+ LayerManager layerManager = (LayerManager) rootEditPart;
+ IFigure layer = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
+ String message = MessageFormat.format(Messages.DDiagramEditorImpl_editorToBeClosedAndReopenedSinceContentIsNotAccessible, status.getMessage());
+ layer.add(new Label(message));
+ }
+ return;
+ }
}
- // Update palette : should be hidden if diagram is not editable
- if (!getPermissionAuthority().canEditInstance(getRepresentation())) {
- notify(REPRESENTATION_EDITION_PERMISSION_DENIED);
+ if (getEditingDomain() != null) {
+ tabbarPostCommitListener = new TabbarRefresher(getEditingDomain());
+ visibilityPostCommitListener = new VisibilityPostCommitListener(getDiagramEditPart());
+ if (isHeaderSectionEnabled()) {
+ diagramHeaderPostCommitListener = new DiagramHeaderPostCommitListener(getEditingDomain(), getDiagramHeader());
+ }
+ // Update palette : should be hidden if diagram is not editable
+ if (!getPermissionAuthority().canEditInstance(getRepresentation())) {
+ notify(REPRESENTATION_EDITION_PERMISSION_DENIED);
+ }
}
}
@@ -551,14 +565,17 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
private void initPermissionAuthority() {
// This IPermissionAuthority is added only on shared
// representations.
- IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(getDiagram().getElement());
- dRepresentationLockStatusListener = new DRepresentationPermissionStatusListener((DSemanticDiagram) getDiagram().getElement(), this);
- permissionAuthority.addAuthorityListener(dRepresentationLockStatusListener);
-
- if (!permissionAuthority.canEditInstance(this.getRepresentation())) {
- notify(SessionListener.REPRESENTATION_EDITION_PERMISSION_DENIED);
- } else if (LockStatus.LOCKED_BY_ME.equals(permissionAuthority.getLockStatus(getDiagram().getElement()))) {
- notify(SessionListener.REPRESENTATION_EDITION_PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY);
+ Diagram diagram = getDiagram();
+ if (diagram != null) {
+ IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(diagram.getElement());
+ dRepresentationLockStatusListener = new DRepresentationPermissionStatusListener((DSemanticDiagram) diagram.getElement(), this);
+ permissionAuthority.addAuthorityListener(dRepresentationLockStatusListener);
+
+ if (!permissionAuthority.canEditInstance(this.getRepresentation())) {
+ notify(SessionListener.REPRESENTATION_EDITION_PERMISSION_DENIED);
+ } else if (LockStatus.LOCKED_BY_ME.equals(permissionAuthority.getLockStatus(getDiagram().getElement()))) {
+ notify(SessionListener.REPRESENTATION_EDITION_PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY);
+ }
}
}
@@ -575,7 +592,7 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
@Override
protected KeyHandler getKeyHandler() {
- if (keyHandler == null) {
+ if (keyHandler == null && session != null) {
keyHandler = super.getKeyHandler();
/* map our custom delete action */
@@ -627,11 +644,12 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
}
private void configureCommandFactoryProviders() {
- /*
- * We add a callback for UI stuffs
- */
- IDiagramCommandFactory diagramCommandFactory = emfCommandFactoryProvider.getCommandFactory(getEditingDomain());
- diagramCommandFactory.setUserInterfaceCallBack(new EMFCommandFactoryUI());
+ /* We add a callback for UI stuffs */
+ TransactionalEditingDomain domain = getEditingDomain();
+ if (domain != null) {
+ IDiagramCommandFactory diagramCommandFactory = emfCommandFactoryProvider.getCommandFactory(domain);
+ diagramCommandFactory.setUserInterfaceCallBack(new EMFCommandFactoryUI());
+ }
}
/**
@@ -642,7 +660,10 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
*/
@Override
protected TransactionalEditingDomain createEditingDomain() {
- return getSession().getTransactionalEditingDomain();
+ if (getSession() != null) {
+ return getSession().getTransactionalEditingDomain();
+ }
+ return null;
}
/**
@@ -694,8 +715,10 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
if (getSession() != null) {
getSession().removeListener(this);
}
- selectElementsListener.dispose();
- selectElementsListener = null;
+ if (selectElementsListener != null) {
+ selectElementsListener.dispose();
+ selectElementsListener = null;
+ }
if (getGraphicalViewer() != null) {
getGraphicalViewer().removeDropTargetListener(transferDropTargetListener);
@@ -745,6 +768,13 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
stopDiagramEventBrokerListener(getEditingDomain());
}
+ @Override
+ public void persistViewerSettings() {
+ if (getDiagram() != null) {
+ super.persistViewerSettings();
+ }
+ }
+
/**
* Dispose all graphical listeners. This method can be called as soon as the
* close of the editor is in progress. This avoids that these listeners
@@ -777,16 +807,23 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
@Override
protected void configureGraphicalViewer() {
- super.configureGraphicalViewer();
+ if (getDiagram() != null) {
+ super.configureGraphicalViewer();
- /* register our menu provider to provide our custom delete action */
- final DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer());
- getDiagramGraphicalViewer().setContextMenu(provider);
- getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
+ /* register our menu provider to provide our custom delete action */
+ final DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer());
+ getDiagramGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
- getOperationHistory().addOperationHistoryListener(operationHistoryListener);
- // add the wheel mouse to zoom
- this.getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
+ getOperationHistory().addOperationHistoryListener(operationHistoryListener);
+ // add the wheel mouse to zoom
+ this.getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
+ } else {
+ workspaceViewerPreferenceStore = new PreferenceStore();
+ if (getDiagramGraphicalViewer() instanceof DiagramGraphicalViewer) {
+ ((DiagramGraphicalViewer) getDiagramGraphicalViewer()).hookWorkspacePreferenceStore(getWorkspaceViewerPreferenceStore());
+ }
+ }
}
private DiagramOutlinePage initOutline() {
@@ -879,12 +916,12 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
return result;
}
}, };
- DiagramOutlinePage outline;
+ DiagramOutlinePage outline = null;
if (isOldUIEnabled()) {
outline = new DiagramOutlineWithBookPages(this.getDiagramEditPart().getModel(), getGraphicalViewer(), outlinePopupMenuActions);
} else {
- outline = new DiagramOutlinePage(this.getDiagramEditPart().getModel(), new OutlineLabelProvider(), new OutlineContentProvider(), new OutlineComparator(), getGraphicalViewer(),
- outlinePopupMenuActions);
+ outline = new DiagramOutlinePage(getDiagramEditPart() != null ? getDiagramEditPart().getModel() : null, new OutlineLabelProvider(), new OutlineContentProvider(), new OutlineComparator(),
+ getGraphicalViewer(), outlinePopupMenuActions);
}
outline.setDiagramWorkbenchPart(this);
return outline;
@@ -896,37 +933,40 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
*/
@Override
public void setFocus() {
- super.setFocus();
-
- final Iterator<EditPart> iterParts = getDiagramGraphicalViewer().getRootEditPart().getChildren().iterator();
- while (iterParts.hasNext()) {
- final EditPart editPart = iterParts.next();
- if (editPart instanceof AbstractDDiagramEditPart && ((GraphicalEditPart) editPart).resolveSemanticElement() instanceof DSemanticDiagram) {
- final DSemanticDiagram semanticElement = (DSemanticDiagram) ((GraphicalEditPart) editPart).resolveSemanticElement();
- if (semanticElement == null || semanticElement.eResource() == null || semanticElement.getTarget() == null || semanticElement.getTarget().eResource() == null) {
- // The session may not be accessible if the session is using
- // CDOResources and the server is down
- if (SessionManager.INSTANCE.getSession(semanticElement.getTarget()) != null) {
- /*
- * The element has been deleted, we should close the
- * editor
- */
- myDialogFactory.editorWillBeClosedInformationDialog(getSite().getShell());
- close(false);
+ if (getDiagram() != null) {
+ super.setFocus();
+ final Iterator<EditPart> iterParts = getDiagramGraphicalViewer().getRootEditPart().getChildren().iterator();
+ while (iterParts.hasNext()) {
+ final EditPart editPart = iterParts.next();
+ if (editPart instanceof AbstractDDiagramEditPart && ((GraphicalEditPart) editPart).resolveSemanticElement() instanceof DSemanticDiagram) {
+ final DSemanticDiagram semanticElement = (DSemanticDiagram) ((GraphicalEditPart) editPart).resolveSemanticElement();
+ if (semanticElement == null || semanticElement.eResource() == null || semanticElement.getTarget() == null || semanticElement.getTarget().eResource() == null) {
+ // The session may not be accessible if the session is
+ // using
+ // CDOResources and the server is down
+ if (SessionManager.INSTANCE.getSession(semanticElement.getTarget()) != null) {
+ /*
+ * The element has been deleted, we should close the
+ * editor
+ */
+ myDialogFactory.editorWillBeClosedInformationDialog(getSite().getShell());
+ close(false);
+ }
+ return;
}
- return;
}
}
- }
- if (getOperationHistory() != null) {
- // See the javadoc of addOperationHistoryListener. If the listener
- // is already registered, the call has no effect.
- // so we can safely add the listener here.
- getOperationHistory().addOperationHistoryListener(this.operationHistoryListener);
- }
+ if (getOperationHistory() != null) {
+ // See the javadoc of addOperationHistoryListener. If the
+ // listener
+ // is already registered, the call has no effect.
+ // so we can safely add the listener here.
+ getOperationHistory().addOperationHistoryListener(this.operationHistoryListener);
+ }
- setEclipseWindowTitle();
+ setEclipseWindowTitle();
+ }
}
private void setEclipseWindowTitle() {
@@ -1071,6 +1111,14 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
}
@Override
+ public DiagramEditPart getDiagramEditPart() {
+ if (getGraphicalViewer() == null) {
+ return null;
+ }
+ return super.getDiagramEditPart();
+ }
+
+ @Override
public IPermissionAuthority getPermissionAuthority() {
if (authority == null) {
authority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(getEditingDomain().getResourceSet());
@@ -1220,7 +1268,7 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
} else if (type == IDiagramWorkbenchPart.class) {
adapter = this;
}
- return adapter != null ? adapter : super.getAdapter(type);
+ return (adapter != null || session == null) ? adapter : super.getAdapter(type);
}
@Override
@@ -1245,7 +1293,7 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
protected void createGraphicalViewer(final Composite parent) {
this.diagramMenuUpdater = new DiagramMenuUpdater(this);
parentComposite = createParentComposite(parent);
- if (!isOldUIEnabled()) {
+ if (!isOldUIEnabled() && session != null) {
setTabbar(new Tabbar(parentComposite, this));
}
createHeaderSection(parentComposite);
@@ -1358,31 +1406,33 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
@Override
protected void initializeGraphicalViewer() {
+ if (getDiagram() != null) {
+ /*
+ * Refresh diagram if needed. Must be done before that
+ */
+ if (DialectUIManager.INSTANCE.isRefreshActivatedOnRepresentationOpening()) {
+ launchRefresh(true);
+ }
- /*
- * Refresh diagram if needed. Must be done before that
- */
- if (DialectUIManager.INSTANCE.isRefreshActivatedOnRepresentationOpening()) {
- launchRefresh(true);
- }
-
- super.initializeGraphicalViewer();
+ super.initializeGraphicalViewer();
- // After EditPart instantiation call arrange command on views marked as
- // to be arranged
- final DiagramEditPart diagramEditPart = getDiagramEditPart();
- if (diagramEditPart != null) {
- SiriusCanonicalLayoutHandler.launchArrangeCommand(diagramEditPart);
- }
+ // After EditPart instantiation call arrange command on views marked
+ // as
+ // to be arranged
+ final DiagramEditPart diagramEditPart = getDiagramEditPart();
+ if (diagramEditPart != null) {
+ SiriusCanonicalLayoutHandler.launchArrangeCommand(diagramEditPart);
+ }
- transferDropTargetListener = new DDiagramEditorTransferDropTargetListener(getGraphicalViewer(), LocalSelectionTransfer.getTransfer());
+ transferDropTargetListener = new DDiagramEditorTransferDropTargetListener(getGraphicalViewer(), LocalSelectionTransfer.getTransfer());
- getGraphicalViewer().addDropTargetListener(transferDropTargetListener);
+ getGraphicalViewer().addDropTargetListener(transferDropTargetListener);
- // Initialize and rebuild the header composite
- if (getDiagramHeader() != null) {
- getDiagramHeader().setGraphicalViewer((ScrollingGraphicalViewer) getGraphicalViewer());
- getDiagramHeader().rebuildHeaderSection();
+ // Initialize and rebuild the header composite
+ if (getDiagramHeader() != null) {
+ getDiagramHeader().setGraphicalViewer((ScrollingGraphicalViewer) getGraphicalViewer());
+ getDiagramHeader().rebuildHeaderSection();
+ }
}
}
@@ -1632,7 +1682,7 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE
// In case the input is based on the DDiagram, we need to updated it to
// use the GMF diagram
IEditorInput updatedEditorInput = input;
- if (input instanceof URIEditorInput) {
+ if (session != null && input instanceof URIEditorInput) {
URI uri = ((URIEditorInput) input).getURI();
if (uri != null && !StringUtil.isEmpty(uri.fragment())) {
EObject eObject = session.getTransactionalEditingDomain().getResourceSet().getEObject(uri, false);
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java
index 504356189a..9bd9849ab0 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2002, 2013 IBM Corporation and others.
+ * Copyright (c) 2002, 2015 IBM Corporation and others.
* 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
@@ -482,23 +482,25 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage {
protected void initializeOverview() {
final LightweightSystem lws = new LightweightSystem(overview);
final RootEditPart rep = graphicalViewer.getRootEditPart();
- final DiagramRootEditPart root = (DiagramRootEditPart) rep;
- thumbnail = new ScrollableThumbnail((Viewport) root.getFigure());
- thumbnail.setSource(root.getLayer(LayerConstants.SCALABLE_LAYERS));
-
- lws.setContents(thumbnail);
- disposeListener = new DisposeListener() {
-
- @Override
- public void widgetDisposed(final DisposeEvent e) {
- if (thumbnail != null) {
- thumbnail.deactivate();
- thumbnail = null;
+ if (rep instanceof DiagramRootEditPart) {
+ final DiagramRootEditPart root = (DiagramRootEditPart) rep;
+ thumbnail = new ScrollableThumbnail((Viewport) root.getFigure());
+ thumbnail.setSource(root.getLayer(LayerConstants.SCALABLE_LAYERS));
+
+ lws.setContents(thumbnail);
+ disposeListener = new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(final DisposeEvent e) {
+ if (thumbnail != null) {
+ thumbnail.deactivate();
+ thumbnail = null;
+ }
}
- }
- };
- getEditor().addDisposeListener(disposeListener);
- this.overviewInitialized = true;
+ };
+ getEditor().addDisposeListener(disposeListener);
+ this.overviewInitialized = true;
+ }
}
/**
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/Tabbar.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/Tabbar.java
index c287512c0f..d92e068552 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/Tabbar.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/Tabbar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES.
* 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
@@ -21,6 +21,7 @@ import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil;
import org.eclipse.sirius.diagram.ui.tools.api.editor.DDiagramEditor;
import org.eclipse.sirius.ecore.extender.business.api.permission.IAuthorityListener;
@@ -105,9 +106,12 @@ public class Tabbar extends Composite implements ISelectionListener, IAuthorityL
private void setPermissionAuthorityListener() {
if (part instanceof DDiagramEditor) {
DDiagramEditor editor = (DDiagramEditor) part;
- permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(editor.getSession().getSessionResource().getResourceSet());
- if (permissionAuthority != null) {
- permissionAuthority.addAuthorityListener(this);
+ Session session = editor.getSession();
+ if (session != null) {
+ permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(session.getSessionResource().getResourceSet());
+ if (permissionAuthority != null) {
+ permissionAuthority.addAuthorityListener(this);
+ }
}
}
}
@@ -146,12 +150,7 @@ public class Tabbar extends Composite implements ISelectionListener, IAuthorityL
return canBeDynamic;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
- * org.eclipse.jface.viewers.ISelection)
- */
+ @Override
public void selectionChanged(IWorkbenchPart partSelected, ISelection selection) {
// nothing to do here. Each item contribution is now responsible for
// refresh himself when selection change.
@@ -197,6 +196,7 @@ public class Tabbar extends Composite implements ISelectionListener, IAuthorityL
private void updateAllItems() {
EclipseUIUtil.displayAsyncExec(new Runnable() {
+ @Override
public void run() {
List<IContributionItem> items = Arrays.asList(manager.getItems());
for (IContributionItem item : items) {
@@ -209,31 +209,23 @@ public class Tabbar extends Composite implements ISelectionListener, IAuthorityL
});
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void notifyIsLocked(EObject instance) {
updateAllItems();
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void notifyIsReleased(EObject instance) {
updateAllItems();
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void notifyIsLocked(Collection<EObject> instances) {
updateAllItems();
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void notifyIsReleased(Collection<EObject> instances) {
updateAllItems();
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/part/SiriusDiagramGraphicalViewer.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/part/SiriusDiagramGraphicalViewer.java
index cc1406eeee..64e24bf38b 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/part/SiriusDiagramGraphicalViewer.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/part/SiriusDiagramGraphicalViewer.java
@@ -341,12 +341,15 @@ public class SiriusDiagramGraphicalViewer extends DiagramGraphicalViewer impleme
@Override
public void setSelection(ISelection newSelection) {
- // This setFocus to null must be provided by the super class directly.
- // The corresponding GEF bugzilla is 458416.
- if (newSelection instanceof IStructuredSelection) {
- setFocus(null);
- }
+ if (getContents() != null) {
+ // This setFocus to null must be provided by the super class
+ // directly.
+ // The corresponding GEF bugzilla is 458416.
+ if (newSelection instanceof IStructuredSelection) {
+ setFocus(null);
+ }
- super.setSelection(newSelection);
+ super.setSelection(newSelection);
+ }
}
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewAction.java
index 2c415585ca..a31ed3a92d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewAction.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewHelper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewHelper.java
index 3aba41d952..08b760a498 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewHelper.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusDiagramPrintPreviewHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -50,17 +50,19 @@ public class SiriusDiagramPrintPreviewHelper extends RenderedPrintPreviewHelper
/**
* {@inheritDoc}
*
- * @see org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.printpreview.RenderedPrintPreviewHelper
- * ;
+ * @see org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.
+ * printpreview.RenderedPrintPreviewHelper ;
*/
@Override
protected DiagramEditPart getDiagramEditPart() {
if (diagramEditPart == null && getDiagramEditorPart() != null) {
final Diagram diagram = getDiagramEditorPart().getDiagram();
- final PreferencesHint preferencesHint = getPreferencesHint(getDiagramEditorPart());
- final DiagramEditPartService tool = new DiagramEditPartService();
- diagramEditPart = tool.createDiagramEditPart(diagram, getVpTempShell(), preferencesHint);
- SiriusDiagramPrintPreviewHelper.initializePreferences(diagramEditPart, preferencesHint);
+ if (diagram != null) {
+ final PreferencesHint preferencesHint = getPreferencesHint(getDiagramEditorPart());
+ final DiagramEditPartService tool = new DiagramEditPartService();
+ diagramEditPart = tool.createDiagramEditPart(diagram, getVpTempShell(), preferencesHint);
+ SiriusDiagramPrintPreviewHelper.initializePreferences(diagramEditPart, preferencesHint);
+ }
}
return super.getDiagramEditPart();
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusEnhancedPrintActionHelper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusEnhancedPrintActionHelper.java
index dfd4cc7ae6..f73e3604ff 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusEnhancedPrintActionHelper.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/print/SiriusEnhancedPrintActionHelper.java
@@ -113,21 +113,23 @@ public class SiriusEnhancedPrintActionHelper implements IPrintActionHelper {
if (obj instanceof DiagramEditor) { // DiagramDocumentEditor
final DiagramEditor dEditor = (DiagramEditor) obj;
Diagram diagram = dEditor.getDiagram();
- String diagramName = dEditor.getPartName();
- if (diagramName == null) {
- diagramName = dEditor.getTitle();
- }
- if (diagramName == null) {
- diagramName = diagram.getName();
- }
+ if (diagram != null) {
+ String diagramName = dEditor.getPartName();
+ if (diagramName == null) {
+ diagramName = dEditor.getTitle();
+ }
+ if (diagramName == null) {
+ diagramName = diagram.getName();
+ }
- Resource resource = diagram.eResource();
- if (resource != null) {
- URI resourceURI = resource.getURI();
- diagramName = resourceURI.toString() + "#" + diagramName; //$NON-NLS-1$
+ Resource resource = diagram.eResource();
+ if (resource != null) {
+ URI resourceURI = resource.getURI();
+ diagramName = resourceURI.toString() + "#" + diagramName; //$NON-NLS-1$
+ }
+ diagramName = makeNameUnique(diagramName, diagramMap.keySet());
+ diagramMap.put(diagramName, diagram);
}
- diagramName = makeNameUnique(diagramName, diagramMap.keySet());
- diagramMap.put(diagramName, diagram);
}
}
return diagramMap;
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/filters/FiltersTableViewer.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/filters/FiltersTableViewer.java
index ba1b901934..28a29309f1 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/filters/FiltersTableViewer.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/filters/FiltersTableViewer.java
@@ -81,7 +81,7 @@ public final class FiltersTableViewer {
tableViewer.setContentProvider(new FiltersContentProvider(adapter, workbenchPart));
tableViewer.setLabelProvider(new FiltersLabelProvider(workbenchPart));
- if (workbenchPart != null) {
+ if (workbenchPart != null && workbenchPart.getDiagram() != null) {
final EObject eObj = workbenchPart.getDiagram().getElement();
if (eObj instanceof DDiagram) {
final DDiagram diagram = (DDiagram) eObj;
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersTableViewer.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersTableViewer.java
index b5255e09e6..ecf63ecc36 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersTableViewer.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersTableViewer.java
@@ -89,7 +89,7 @@ public final class LayersTableViewer {
tableViewer.setContentProvider(new LayersContentProvider(adapter, sessionListener, diagramPart));
tableViewer.setLabelProvider(new LayersLabelProvider(diagramPart));
- if (diagramPart != null) {
+ if (diagramPart != null && diagramPart.getDiagram() != null) {
final EObject eObj = diagramPart.getDiagram().getElement();
if (eObj instanceof DDiagram) {
final DDiagram diagram = (DDiagram) eObj;
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java
index 0be97390fd..87409792e7 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java
@@ -240,6 +240,9 @@ public final class Messages {
public static String CustomTreeSelectionDialog_uncheckAllButtonTooltip;
@TranslatableMessage
+ public static String DDiagramEditorImpl_editorToBeClosedAndReopenedSinceContentIsNotAccessible;
+
+ @TranslatableMessage
public static String DDiagramEditorImpl_cdoServerConnectionPbMsg;
@TranslatableMessage
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index b0a0de5ba6..a3cfa5b698 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -18,6 +18,9 @@
<li>
<a href="#SpecifierVisibleChanges">Specifier-Visible Changes</a>
</li>
+ <li>
+ <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a>
+ </li>
</ol>
</li>
<li>
@@ -30,7 +33,7 @@
<a href="#SpecifierVisibleChanges2">Specifier-Visible Changes</a>
</li>
<li>
- <a href="#DeveloperVisibleChanges">Developer-Visible Changes</a>
+ <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a>
</li>
</ol>
</li>
@@ -44,7 +47,7 @@
<a href="#SpecifierVisibleChanges3">Specifier-Visible Changes</a>
</li>
<li>
- <a href="#DeveloperVisibleChanges2">Developer-Visible Changes</a>
+ <a href="#DeveloperVisibleChanges3">Developer-Visible Changes</a>
</li>
</ol>
</li>
@@ -73,6 +76,15 @@
<ul>
<li><span class="label label-info">Modified</span> The use of type literals in operations like filter() or oclIsKindOf() requires to explicitly add the domain meta-models plug-ins to the dependencies of the Viewpoint Specification Project. The documentation has been modified to recommend this.</li>
</ul>
+ <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
+ <h4 id="Changesinorg.eclipse.sirius">Changes in
+ <code>org.eclipse.sirius</code>
+ </h4>
+ <ul>
+ <li><span class="label label-success">Added</span> The method
+ <code>org.eclipse.sirius.ui.business.api.session.SessionEditorInput.getStatus()</code> has been added to have the status about session opening, i.e. if it has been correctly opened, cancelled or an exception has occurred.
+ </li>
+ </ul>
<h2 id="sirius3.1.0">Changes in Sirius 3.1.0</h2>
<h3 id="UserVisibleChanges">User-Visible Changes</h3>
<ul>
@@ -160,7 +172,7 @@
<code>IPermissionAuthority</code>) of the potential to delete objects. This is the reverse order of what was done before, and can have performance impacts if the precondition is slow. The specifier will to take care to ensure a good performance for the precondition expression of the delete tool.
</li>
</ul>
- <h3 id="DeveloperVisibleChanges">Developer-Visible Changes</h3>
+ <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3>
<h4 id="Partialsupportforinternationalization">Partial support for internationalization</h4>
<p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#171;language packs&#187; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
<p>Some API changes were required to enable this. While technically breaking changes if interpreting strictly the OSGi versioning rules, the major version number of the impacted bundles was not incremented as the changes only concern classes that should not impact the vast majority of users. Most breaking changes concern the plug-in/activator classes from each bundle. They are:</p>
@@ -401,7 +413,7 @@
<code>org.eclipse.sirius.common.tools.api.contentassist.ContentProposalBuilder</code> used to build the content proposals with their various parameters more easily.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius">Changes in
+ <h4 id="Changesinorg.eclipse.sirius2">Changes in
<code>org.eclipse.sirius</code>
</h4>
<ul>
@@ -709,7 +721,7 @@
<em>EStructuralFeature</em> (inherited or with same name).
</li>
</ul>
- <h3 id="DeveloperVisibleChanges2">Developer-Visible Changes</h3>
+ <h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3>
<p>The most important and impacting changes in this release are (details below in plug-in specific sections):</p>
<ul>
<li><span class="label label-success">Added</span> The new extension point
@@ -910,7 +922,7 @@
<code>org.eclipse.sirius.common.ui.ext</code>.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius2">Changes in
+ <h4 id="Changesinorg.eclipse.sirius3">Changes in
<code>org.eclipse.sirius</code>
</h4>
<ul>
@@ -1621,7 +1633,7 @@
<li>&#171;Lozenge&#187; is replaced by &#171;Diamond&#187; in diagram style.</li>
</ul>
<h3 id="APIChanges">API Changes</h3>
- <h4 id="Changesinorg.eclipse.sirius3">Changes in
+ <h4 id="Changesinorg.eclipse.sirius4">Changes in
<code>org.eclipse.sirius</code>
</h4>
<ul>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 3293c65203..a02af930f8 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -10,6 +10,12 @@ h3. Specifier-Visible Changes
* <span class="label label-info">Modified</span> The use of type literals in operations like filter() or oclIsKindOf() requires to explicitly add the domain meta-models plug-ins to the dependencies of the Viewpoint Specification Project. The documentation has been modified to recommend this.
+h3. Developer-Visible Changes
+
+h4. Changes in @org.eclipse.sirius@
+
+* <span class="label label-success">Added</span> The method @org.eclipse.sirius.ui.business.api.session.SessionEditorInput.getStatus()@ has been added to have the status about session opening, i.e. if it has been correctly opened, cancelled or an exception has occurred.
+
h2(#sirius3.1.0). Changes in Sirius 3.1.0
h3. User-Visible Changes
diff --git a/plugins/org.eclipse.sirius.table.ui/plugin.properties b/plugins/org.eclipse.sirius.table.ui/plugin.properties
index 18cf184d4e..477d1df4a7 100644
--- a/plugins/org.eclipse.sirius.table.ui/plugin.properties
+++ b/plugins/org.eclipse.sirius.table.ui/plugin.properties
@@ -275,6 +275,7 @@ _UI_DTableElementStyle_backgroundColor_feature = Background Color
_UI_DTableElementStyle_defaultForegroundStyle_feature = Default Foreground Style
_UI_DTableElementStyle_defaultBackgroundStyle_feature = Default Background Style
+AbstractDTableEditor_editorToBeClosedAndReopenedSinceContentIsNotAccessible={0}\nContent access has failed at editor opening, you can try to reopen this editor.
AbstractDTableEditor_tableNotSaved = This table was not saved. You can close the editor
Action_cancelled = Cancelled
Action_error = Error
diff --git a/plugins/org.eclipse.sirius.table.ui/src-gen/org/eclipse/sirius/table/metamodel/table/provider/Messages.java b/plugins/org.eclipse.sirius.table.ui/src-gen/org/eclipse/sirius/table/metamodel/table/provider/Messages.java
index 901c0bb9ef..892633a9e9 100644
--- a/plugins/org.eclipse.sirius.table.ui/src-gen/org/eclipse/sirius/table/metamodel/table/provider/Messages.java
+++ b/plugins/org.eclipse.sirius.table.ui/src-gen/org/eclipse/sirius/table/metamodel/table/provider/Messages.java
@@ -28,6 +28,9 @@ public final class Messages {
public static String AbstractDTableEditor_tableNotSaved;
@TranslatableMessage
+ public static String AbstractDTableEditor_editorToBeClosedAndReopenedSinceContentIsNotAccessible;
+
+ @TranslatableMessage
public static String Action_cancelled;
@TranslatableMessage
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/AbstractDTableEditor.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/AbstractDTableEditor.java
index ec0a655cf7..60d9e6ac01 100644
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/AbstractDTableEditor.java
+++ b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/AbstractDTableEditor.java
@@ -58,11 +58,16 @@ import org.eclipse.sirius.tools.api.profiler.SiriusTasksKey;
import org.eclipse.sirius.ui.business.api.descriptor.ComposedImageDescriptor;
import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.sirius.ui.business.api.dialect.marker.TraceabilityMarkerNavigationProvider;
+import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
+import org.eclipse.sirius.ui.tools.internal.editor.AbstractDTableViewerManager;
import org.eclipse.sirius.ui.tools.internal.editor.AbstractDTreeEditor;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -230,6 +235,31 @@ public abstract class AbstractDTableEditor extends AbstractDTreeEditor implement
@Override
public void createPartControl(final Composite parent) {
+ // Display the status message to inform user about reason why the
+ // session opening failed
+ if (session == null && getEditorInput() instanceof SessionEditorInput) {
+ SessionEditorInput sessionEditorInput = (SessionEditorInput) getEditorInput();
+ IStatus status = sessionEditorInput.getStatus();
+ if (status.getSeverity() >= IStatus.ERROR) {
+ Composite composite = new Composite(parent, SWT.NO_FOCUS);
+ control = composite;
+ GridLayout gridLayout = new GridLayout();
+ composite.setLayout(gridLayout);
+ StyledText widget = new StyledText(composite, SWT.NO_FOCUS | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
+ widget.setLineAlignment(0, widget.getLineCount(), SWT.CENTER);
+ widget.setAlignment(SWT.CENTER);
+ String message = MessageFormat.format(org.eclipse.sirius.table.metamodel.table.provider.Messages.AbstractDTableEditor_editorToBeClosedAndReopenedSinceContentIsNotAccessible,
+ status.getMessage());
+ widget.setText(message);
+ GridData layoutData = new GridData();
+ layoutData.grabExcessHorizontalSpace = true;
+ layoutData.grabExcessVerticalSpace = true;
+ layoutData.horizontalAlignment = SWT.CENTER;
+ layoutData.verticalAlignment = SWT.CENTER;
+ widget.setLayoutData(layoutData);
+ return;
+ }
+ }
super.createPartControl(parent);
DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.CREATE_TABLE_KEY);
@@ -290,8 +320,14 @@ public abstract class AbstractDTableEditor extends AbstractDTreeEditor implement
@Override
public Control getControl() {
- TreeViewer treeViewer = this.getTableViewer().getTreeViewer();
- return treeViewer.getTree();
+ if (control == null) {
+ AbstractDTableViewerManager tableViewer = getTableViewer();
+ if (tableViewer != null) {
+ TreeViewer treeViewer = tableViewer.getTreeViewer();
+ control = treeViewer.getTree();
+ }
+ }
+ return control;
}
@Override
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableActionBarContributor.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableActionBarContributor.java
index ae590e55a4..bedff6eb08 100644
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableActionBarContributor.java
+++ b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/tools/internal/editor/provider/DTableActionBarContributor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -10,8 +10,17 @@
*******************************************************************************/
package org.eclipse.sirius.table.ui.tools.internal.editor.provider;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.sirius.table.ui.tools.internal.editor.AbstractDTableEditor;
+import org.eclipse.sirius.table.ui.tools.internal.editor.DTableCrossEditor;
+import org.eclipse.sirius.table.ui.tools.internal.editor.DTableViewerManager;
+import org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorCreateLineMenuAction;
+import org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorCreateTargetColumnMenuAction;
+import org.eclipse.sirius.table.ui.tools.internal.editor.action.PrintAction;
+import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
+import org.eclipse.sirius.ui.tools.internal.editor.AbstractDTableViewerManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorPart;
@@ -21,14 +30,6 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.IPage;
-import org.eclipse.sirius.table.ui.tools.internal.editor.AbstractDTableEditor;
-import org.eclipse.sirius.table.ui.tools.internal.editor.DTableCrossEditor;
-import org.eclipse.sirius.table.ui.tools.internal.editor.DTableViewerManager;
-import org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorCreateLineMenuAction;
-import org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorCreateTargetColumnMenuAction;
-import org.eclipse.sirius.table.ui.tools.internal.editor.action.PrintAction;
-import org.eclipse.sirius.ui.tools.internal.editor.AbstractDTableViewerManager;
-
/**
* This is a contributor for an DTable editor.
*
@@ -75,25 +76,27 @@ public class DTableActionBarContributor extends EditingDomainActionBarContributo
@Override
public void setActiveEditor(IEditorPart part) {
- boolean updateCreateMenus = part != activeEditor && part != null;
- super.setActiveEditor(part);
- if (updateCreateMenus && activeEditor instanceof AbstractDTableEditor) {
- AbstractDTableViewerManager tableViewer = ((AbstractDTableEditor) activeEditor).getTableViewer();
- if (tableViewer instanceof DTableViewerManager) {
- // Add the CreateLine menu of the toolbar
- addCreateLineMenu(((DTableViewerManager) tableViewer).getCreateLineMenu());
- }
- }
- if (activeEditor instanceof DTableCrossEditor) {
- DTableCrossEditor tableCrossEditor = (DTableCrossEditor) activeEditor;
- // Add the CreateTargetColumn menu of the toolbar
- IEditorActionBarContributor actionBarContributor = tableCrossEditor.getEditorSite().getActionBarContributor();
- if (actionBarContributor instanceof DTableActionBarContributor) {
- DTableActionBarContributor dTableActionBarContributor = (DTableActionBarContributor) actionBarContributor;
- AbstractDTableViewerManager tableViewer = tableCrossEditor.getTableViewer();
+ if (part != null && part.getEditorInput() instanceof SessionEditorInput && ((SessionEditorInput) part.getEditorInput()).getStatus().getSeverity() < IStatus.ERROR) {
+ boolean updateCreateMenus = part != activeEditor && part != null;
+ super.setActiveEditor(part);
+ if (updateCreateMenus && activeEditor instanceof AbstractDTableEditor) {
+ AbstractDTableViewerManager tableViewer = ((AbstractDTableEditor) activeEditor).getTableViewer();
if (tableViewer instanceof DTableViewerManager) {
- DTableViewerManager dTableViewerManager = (DTableViewerManager) tableViewer;
- dTableActionBarContributor.addCreateTargetColumnMenu(dTableViewerManager.getCreateTargetColumnMenu());
+ // Add the CreateLine menu of the toolbar
+ addCreateLineMenu(((DTableViewerManager) tableViewer).getCreateLineMenu());
+ }
+ }
+ if (activeEditor instanceof DTableCrossEditor) {
+ DTableCrossEditor tableCrossEditor = (DTableCrossEditor) activeEditor;
+ // Add the CreateTargetColumn menu of the toolbar
+ IEditorActionBarContributor actionBarContributor = tableCrossEditor.getEditorSite().getActionBarContributor();
+ if (actionBarContributor instanceof DTableActionBarContributor) {
+ DTableActionBarContributor dTableActionBarContributor = (DTableActionBarContributor) actionBarContributor;
+ AbstractDTableViewerManager tableViewer = tableCrossEditor.getTableViewer();
+ if (tableViewer instanceof DTableViewerManager) {
+ DTableViewerManager dTableViewerManager = (DTableViewerManager) tableViewer;
+ dTableActionBarContributor.addCreateTargetColumnMenu(dTableViewerManager.getCreateTargetColumnMenu());
+ }
}
}
}
diff --git a/plugins/org.eclipse.sirius.tree.ui/plugin.properties b/plugins/org.eclipse.sirius.tree.ui/plugin.properties
index c6acfaf3a5..e435e77461 100644
--- a/plugins/org.eclipse.sirius.tree.ui/plugin.properties
+++ b/plugins/org.eclipse.sirius.tree.ui/plugin.properties
@@ -12,6 +12,7 @@
pluginName = Sirius Tree Specification Editor
providerName = Eclipse Modeling Project
+DTreeEditor_editorToBeClosedAndReopenedSinceContentIsNotAccessible={0}\nContent access has failed at editor opening, you can try to reopen this editor.
DTreeEditor_treeModelUnsaved = This tree was not saved. You can close the editor
DTreeItemDropListener_ambigousDropWarning = There are more than one drop description that match the dropped element : {0} ({1} and {2}).
DTreeItemDropListener_dragAndDropCommand = Drag And Drop
@@ -30,9 +31,10 @@ EditorRefreshAction_treeRefreshError = Error while refreshing tree
ExpandDTreeItemRunnableWithProgress_expandTreeItem = Expand {0} tree item
ExpandDTreeItemRunnableWithProgress_treeItemCollapsing = Tree item collapsing
ExpandDTreeItemRunnableWithProgress_treeItemExpanding = Tree item expanding
-HierarchyLabelTreeProvider_elementWithoutName = Element whithout name
+HierarchyLabelTreeProvider_elementWithoutName = Element without name
RefreshAction_refreshTreeElement = Refresh Tree Element
TreeDialectUIServices_errorOpeningEditor = tree editor opening error
+TreeDialectUIServices_errorClosingEditor = tree editor closing error
TreeDialectUIServices_newTree = New Tree
TreeDialectUIServices_treeOpening = tree opening
TreeItemExpansionManager_expandOrCollaseError = Error while {0}
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java
index 353879be85..013344d5b4 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java
@@ -148,6 +148,7 @@ public class TreeDialectUIServices implements DialectUIServices {
} catch (NullPointerException e) {
// we might have an exception closing an editor which is
// already in trouble
+ TreeUIPlugin.getPlugin().log(new Status(IStatus.ERROR, TreeUIPlugin.ID, Messages.TreeDialectUIServices_errorOpeningEditor, e));
}
// We suppose it is closed.
result = true;
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/provider/Messages.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/provider/Messages.java
index 47d04ce175..1d1228eb9d 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/provider/Messages.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/provider/Messages.java
@@ -27,6 +27,9 @@ public final class Messages {
// CHECKSTYLE:OFF
@TranslatableMessage
+ public static String DTreeEditor_editorToBeClosedAndReopenedSinceContentIsNotAccessible;
+
+ @TranslatableMessage
public static String DTreeEditor_treeModelUnsaved;
@TranslatableMessage
@@ -90,6 +93,9 @@ public final class Messages {
public static String TreeDialectUIServices_errorOpeningEditor;
@TranslatableMessage
+ public static String TreeDialectUIServices_errorClosingEditor;
+
+ @TranslatableMessage
public static String TreeDialectUIServices_newTree;
@TranslatableMessage
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeActionBarContributor.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeActionBarContributor.java
index 901451eb78..a287e66d69 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeActionBarContributor.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeActionBarContributor.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.sirius.tree.ui.tools.internal.editor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.sirius.tree.ui.tools.internal.editor.actions.EditorCreateTreeItemMenuAction;
+import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
import org.eclipse.ui.IWorkbenchActionConstants;
/**
@@ -34,4 +36,10 @@ public class DTreeActionBarContributor extends EditingDomainActionBarContributor
toolBarManager.update(true);
}
+ @Override
+ public void update() {
+ if (activeEditor != null && activeEditor.getEditorInput() instanceof SessionEditorInput && ((SessionEditorInput) activeEditor.getEditorInput()).getStatus().getSeverity() < IStatus.ERROR) {
+ super.update();
+ }
+ }
}
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeEditor.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeEditor.java
index b6c39357c3..54d1c03b8d 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeEditor.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/tools/internal/editor/DTreeEditor.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.tree.ui.tools.internal.editor;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -21,6 +22,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.URI;
@@ -49,11 +51,16 @@ import org.eclipse.sirius.tree.ui.tools.internal.commands.EMFCommandFactoryUI;
import org.eclipse.sirius.ui.business.api.descriptor.ComposedImageDescriptor;
import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.sirius.ui.business.api.dialect.marker.TraceabilityMarkerNavigationProvider;
+import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
+import org.eclipse.sirius.ui.tools.internal.editor.AbstractDTableViewerManager;
import org.eclipse.sirius.ui.tools.internal.editor.AbstractDTreeEditor;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
@@ -188,6 +195,30 @@ public class DTreeEditor extends AbstractDTreeEditor implements org.eclipse.siri
@Override
public void createPartControl(final Composite parent) {
+ // Display the status message to inform user about reason why the
+ // session opening failed
+ if (session == null && getEditorInput() instanceof SessionEditorInput) {
+ SessionEditorInput sessionEditorInput = (SessionEditorInput) getEditorInput();
+ IStatus status = sessionEditorInput.getStatus();
+ if (status.getSeverity() >= IStatus.ERROR) {
+ Composite composite = new Composite(parent, SWT.NO_FOCUS);
+ control = composite;
+ GridLayout gridLayout = new GridLayout();
+ composite.setLayout(gridLayout);
+ StyledText widget = new StyledText(composite, SWT.NO_FOCUS | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
+ widget.setLineAlignment(0, widget.getLineCount(), SWT.CENTER);
+ widget.setAlignment(SWT.CENTER);
+ String message = MessageFormat.format(Messages.DTreeEditor_editorToBeClosedAndReopenedSinceContentIsNotAccessible, status.getMessage());
+ widget.setText(message);
+ GridData layoutData = new GridData();
+ layoutData.grabExcessHorizontalSpace = true;
+ layoutData.grabExcessVerticalSpace = true;
+ layoutData.horizontalAlignment = SWT.CENTER;
+ layoutData.verticalAlignment = SWT.CENTER;
+ widget.setLayoutData(layoutData);
+ return;
+ }
+ }
super.createPartControl(parent);
// DslCommonPlugin.PROFILER.startWork(SiriusTasks.CREATE_TREE);
@@ -251,8 +282,14 @@ public class DTreeEditor extends AbstractDTreeEditor implements org.eclipse.siri
@Override
public Control getControl() {
- TreeViewer treeViewer = this.getTableViewer().getTreeViewer();
- return treeViewer.getTree();
+ if (control == null) {
+ AbstractDTableViewerManager tableViewer = getTableViewer();
+ if (tableViewer != null) {
+ TreeViewer treeViewer = tableViewer.getTreeViewer();
+ control = treeViewer.getTree();
+ }
+ }
+ return control;
}
private void launchRefresh(boolean loading) {
@@ -443,9 +480,7 @@ public class DTreeEditor extends AbstractDTreeEditor implements org.eclipse.siri
display.asyncExec(new Runnable() {
@Override
public void run() {
- if (treeViewerManager != null) {
- getSite().getPage().closeEditor(DTreeEditor.this, save);
- }
+ getSite().getPage().closeEditor(DTreeEditor.this, save);
}
});
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java
index 85521c9e53..13cad86428 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java
@@ -14,8 +14,10 @@ import java.lang.ref.WeakReference;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.util.URI;
@@ -55,6 +57,8 @@ public class SessionEditorInput extends URIEditorInput {
private WeakReference<EObject> inputRef;
+ private IStatus status = Status.OK_STATUS;
+
/**
* Create a new SessionEditorInput with the current session and ui session.
*
@@ -220,6 +224,7 @@ public class SessionEditorInput extends URIEditorInput {
// case: the session lifecycle is not safe enough to try to open a
// previously closed session.
if (sessionFromURI == null && restore) {
+ status = Status.OK_STATUS;
sessionFromURI = SessionManager.INSTANCE.getSession(sessionModelURI, new NullProgressMonitor());
if (sessionFromURI != null && !sessionFromURI.isOpen()) {
sessionFromURI.open(new NullProgressMonitor());
@@ -240,12 +245,16 @@ public class SessionEditorInput extends URIEditorInput {
uiSession.open();
}
}
- } catch (IllegalStateException e) {
+ } catch (OperationCanceledException e) {
sessionFromURI = null;
+ status = new Status(IStatus.CANCEL, SiriusEditPlugin.ID, e.getLocalizedMessage(), e); // $NON-NLS-1$
// Silent catch: can happen if failing to retrieve the session from
// its URI
- } catch (OperationCanceledException e) {
+ // CHECKSTYLE:OFF
+ } catch (RuntimeException e) {
+ // CHECKSTYLE:ON
sessionFromURI = null;
+ status = new Status(IStatus.ERROR, SiriusEditPlugin.ID, e.getLocalizedMessage(), e); // $NON-NLS-1$
// Silent catch: can happen if failing to retrieve the session from
// its URI
}
@@ -337,12 +346,30 @@ public class SessionEditorInput extends URIEditorInput {
return exists;
}
+ /**
+ * Get the status of the session opening from this
+ * {@link SessionEditorInput}.
+ *
+ * <ul>
+ * <li>A status with severity {@link IStatus#CANCEL} is returned for a
+ * session opening canceled through {@link OperationCanceledException}.</li>
+ * <li>A status with severity {@link IStatus#ERROR} is returned for a
+ * session opening failing because of another {@link RuntimeException}.</li>
+ * <li>Otherwise a status with severity {@link IStatus#OK} is returned.</li>
+ * </ul>
+ *
+ * @return the status of the session opening, null is never returned
+ */
+ public IStatus getStatus() {
+ return status;
+ }
+
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
Object a = super.getAdapter(adapter);
if (IFile.class == adapter && a == null) {
if (EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) {
- Session inputSession = getSession();
+ Session inputSession = getSession(false);
if (inputSession != null && inputSession.isOpen()) {
a = EclipseUtil.getAdatper(adapter, inputSession.getSessionResource().getURI());
}
@@ -364,10 +391,15 @@ public class SessionEditorInput extends URIEditorInput {
public boolean equals(Object o) {
boolean equals = this == o || o instanceof SessionEditorInput && getURI().equals(((SessionEditorInput) o).getURI());
if (equals && o instanceof SessionEditorInput) {
- EObject input = getInput(false);
- if (input != null) {
- SessionEditorInput otherSessionEditorInput = (SessionEditorInput) o;
- return input.equals(otherSessionEditorInput.getInput(false));
+ SessionEditorInput otherSessionEditorInput = (SessionEditorInput) o;
+ IStatus otherStatus = otherSessionEditorInput.getStatus();
+ if (status != otherStatus) {
+ equals = false;
+ } else {
+ EObject input = getInput(false);
+ if (input != null) {
+ equals = input.equals(otherSessionEditorInput.getInput(false));
+ }
}
}
return equals;
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInputFactory.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInputFactory.java
index 93ddcdb240..0cfe47194e 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInputFactory.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInputFactory.java
@@ -49,18 +49,7 @@ public class SessionEditorInputFactory extends URIEditorInputFactory {
@Override
public IAdaptable createElement(IMemento memento) {
IAdaptable element = super.createElement(memento);
-
- if (element instanceof SessionEditorInput) {
- /*
- * If the session editor input is not able to retrieve a session, do
- * not let Eclipse try to restore the editor from the memento, it
- * might lead to a lot of StackOverflowError and
- * NullPointerException.
- */
- if (((SessionEditorInput) element).getSession() == null) {
- element = null;
- }
- } else {
+ if (!(element instanceof SessionEditorInput)) {
/*
* The memento indicates that the expected restored editor input
* should be an instance of SessionEditorInput. If it is not the
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java
index 045b4dd710..11913ed14c 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/AbstractDTreeEditor.java
@@ -64,6 +64,7 @@ import org.eclipse.sirius.viewpoint.provider.Messages;
import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IActionBars;
@@ -90,8 +91,8 @@ import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributo
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
*/
-public abstract class AbstractDTreeEditor extends EditorPart implements DialectEditor, IViewerProvider, ITabbedPropertySheetPageContributor, IEditingDomainProvider, IReusableEditor, SessionListener,
- ISaveablesSource, IPageListener {
+public abstract class AbstractDTreeEditor extends EditorPart
+ implements DialectEditor, IViewerProvider, ITabbedPropertySheetPageContributor, IEditingDomainProvider, IReusableEditor, SessionListener, ISaveablesSource, IPageListener {
/** The PERMISSION_GRANTED_TO_CURRENT_USER_EXCLUSIVELY icon descriptor. */
private static final ImageDescriptor LOCK_BY_ME_IMAGE_DESCRIPTOR = SiriusEditPlugin.Implementation
@@ -117,6 +118,9 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
*/
protected AbstractDTableViewerManager treeViewerManager;
+ /** The control of this editor. */
+ protected Control control;
+
/**
* The session.
*/
@@ -256,7 +260,7 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
@Override
public TransactionalEditingDomain getEditingDomain() {
- return session.getTransactionalEditingDomain();
+ return session != null ? session.getTransactionalEditingDomain() : null;
}
public IActionBars getActionBars() {
@@ -327,7 +331,9 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
SessionEditorInput sessionEditorInput = (SessionEditorInput) input;
final URI uri = sessionEditorInput.getURI();
this.session = sessionEditorInput.getSession();
- setRepresentation(uri, false);
+ if (session != null) {
+ setRepresentation(uri, false);
+ }
} else if (input instanceof URIEditorInput) {
/* This happens when Eclipse is launched with an open tree editor */
final URI uri = ((URIEditorInput) input).getURI();
@@ -338,14 +344,13 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
if (session != null) {
session.addListener(this);
- }
-
- configureCommandFactoryProviders();
+ configureCommandFactoryProviders();
- final IEditingSession uiSession = SessionUIManager.INSTANCE.getOrCreateUISession(this.session);
- uiSession.open();
- uiSession.attachEditor(this);
- setAccessor(SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(getRepresentation()));
+ IEditingSession uiSession = SessionUIManager.INSTANCE.getOrCreateUISession(this.session);
+ uiSession.open();
+ uiSession.attachEditor(this);
+ setAccessor(SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(getRepresentation()));
+ }
DRepresentation representation = getRepresentation();
if (representation != null) {
@@ -397,8 +402,7 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
@Override
public boolean isDirty() {
- final boolean dirty = this.session.getStatus() == SessionStatus.DIRTY;
- return dirty;
+ return session != null && session.getStatus() == SessionStatus.DIRTY;
}
@Override
@@ -451,6 +455,8 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
}
checkSemanticAssociation();
+ } else if (control != null) {
+ control.setFocus();
}
}
@@ -573,7 +579,10 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
@Override
public void dispose() {
-
+ if (control != null) {
+ control.dispose();
+ control = null;
+ }
if (dRepresentationLockStatusListener != null) {
IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(getRepresentation());
permissionAuthority.removeAuthorityListener(dRepresentationLockStatusListener);
@@ -633,7 +642,7 @@ public abstract class AbstractDTreeEditor extends EditorPart implements DialectE
}
}
-
+
public AdapterFactory getAdapterFactory() {
return adapterFactory;
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/UndoRedoActionHandler.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/UndoRedoActionHandler.java
index 62cc34e353..a5f7b9c19e 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/UndoRedoActionHandler.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/UndoRedoActionHandler.java
@@ -96,7 +96,7 @@ public class UndoRedoActionHandler extends Action {
*/
protected IUndoContext getUndoContext() {
if (undoContext == null) {
- if (domain.getCommandStack() instanceof IWorkspaceCommandStack) {
+ if (domain != null && domain.getCommandStack() instanceof IWorkspaceCommandStack) {
// We use the command stack to get the default Undo Context
undoContext = ((IWorkspaceCommandStack) domain.getCommandStack()).getDefaultUndoContext();
}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java
index f6cd3e229c..949be091f4 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/OpenRepresentationsFileJob.java
@@ -70,8 +70,6 @@ public class OpenRepresentationsFileJob extends AbstractRepresentationsFileJob {
*/
public static final String JOB_LABEL = Messages.OpenRepresentationsFileJob_label;
- private static final String QUOTE = "\""; //$NON-NLS-1$
-
/**
* The list of representations files to load. This list is exclusive with
* the list of modeling projects.
@@ -299,35 +297,43 @@ public class OpenRepresentationsFileJob extends AbstractRepresentationsFileJob {
* @return Resource associated to session.
*/
public Set<Session> performOpenSession(URI representationsFileURI, IProgressMonitor monitor) {
- monitor.beginTask(Messages.OpenRepresentationsFileJob_loadRepresentationsTask, 16);
Set<Session> openedSessions = new HashSet<Session>();
- if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(representationsFileURI.fileExtension())) {
- monitor.worked(1);
- Session session = SessionManager.INSTANCE.getSession(representationsFileURI, new SubProgressMonitor(monitor, 10));
- // Open the session if needed (load the referenced models by
- // a ResolveAll call)
- monitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_loadReferencedModelsTask, representationsFileURI.lastSegment()));
- if (session != null) {
- if (!session.isOpen()) {
- session.open(new SubProgressMonitor(monitor, 4));
- }
- IEditingSession editingSession;
- // JGO : Do not create an editing session in case the session is
- // null
- // the session could be null if the session is not a local
- // session (CDO for example) and
- // if the remote CDO server is unreachable
- editingSession = SessionUIManager.INSTANCE.getOrCreateUISession(session);
- if (!editingSession.isOpen()) {
- editingSession.open();
- }
- if (openedSessions != null) {
- openedSessions.add(session);
+ try {
+ monitor.beginTask(Messages.OpenRepresentationsFileJob_loadRepresentationsTask, 16);
+ if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(representationsFileURI.fileExtension())) {
+ monitor.worked(1);
+ Session session = SessionManager.INSTANCE.getSession(representationsFileURI, new SubProgressMonitor(monitor, 10));
+ // Open the session if needed (load the referenced models by
+ // a ResolveAll call)
+ monitor.subTask(MessageFormat.format(Messages.OpenRepresentationsFileJob_loadReferencedModelsTask, representationsFileURI.lastSegment()));
+ if (session != null) {
+ if (!session.isOpen()) {
+ session.open(new SubProgressMonitor(monitor, 4));
+ }
+ IEditingSession editingSession;
+ // JGO : Do not create an editing session in case the
+ // session is
+ // null
+ // the session could be null if the session is not a local
+ // session (CDO for example) and
+ // if the remote CDO server is unreachable
+ editingSession = SessionUIManager.INSTANCE.getOrCreateUISession(session);
+ if (!editingSession.isOpen()) {
+ editingSession.open();
+ }
+ if (openedSessions != null) {
+ openedSessions.add(session);
+ }
}
+ monitor.worked(1);
}
- monitor.worked(1);
+ // CHECKSTYLE:OFF
+ } catch (RuntimeException e) {
+ // CHECKSTYLE:ON
+ SiriusEditPlugin.getPlugin().log(e);
+ } finally {
+ monitor.done();
}
- monitor.done();
return openedSessions;
}
diff --git a/plugins/org.eclipse.sirius/plugin.properties b/plugins/org.eclipse.sirius/plugin.properties
index 5546bd16fa..043f22d127 100644
--- a/plugins/org.eclipse.sirius/plugin.properties
+++ b/plugins/org.eclipse.sirius/plugin.properties
@@ -215,7 +215,7 @@ SaveSessionJob_sessionSavingMsg = Session saving
Saver_savingErrorMsg = Core exception while saving session
SelectionWizardDescriptionImpl_title = Selection Wizard
SessionFactoryImpl_EmptyContentErrorMsg = session creation failed: the resource content is empty.
-SessionFactoryImpl_creationFailedErrorMsg = session creation failed
+SessionFactoryImpl_creationFailedErrorMsg = Session creation failed
SessionFactoryImpl_sessionCreation = Session creation
SessionFactoryImpl_loadingError = Error while loading representations file
SessionFactoryImpl_sessionLoadingMsg = Session loading
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/SessionManagerImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/SessionManagerImpl.java
index 9e4047a509..abe7c9cd65 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/SessionManagerImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/SessionManagerImpl.java
@@ -252,14 +252,12 @@ public class SessionManagerImpl extends SessionManagerEObjectImpl implements Ses
try {
session = SessionFactory.INSTANCE.createSession(sessionModelURI, monitor);
} catch (CoreException e) {
- SiriusPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, SiriusPlugin.ID, MessageFormat.format(Messages.SessionManagerImpl_representationsFileLoadingErrorMsg, sessionModelURI.toPlatformString(true)), e));
if (optionalResource.some()) {
MarkerUtil.addMarkerFor(optionalResource.get(),
MessageFormat.format(Messages.SessionManagerImpl_representationsFileLoadingSeeErrorLogMsg, e.getCause() != null ? e.getCause().getMessage() : e.getMessage()),
IMarker.SEVERITY_ERROR, MarkerRuntimeLogger.MARKER_TYPE);
}
- return null;
+ throw new RuntimeException(e.getLocalizedMessage(), e);
}
}
return session;
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
index 3067a08dfa..0f5bf2d747 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
@@ -23,7 +23,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
@@ -1171,7 +1170,9 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
DslCommonPlugin.PROFILER.stopWork(SiriusTasksKey.OPEN_SESSION_KEY);
notifyListeners(SessionListener.OPENED);
monitor.worked(1);
- } catch (OperationCanceledException e) {
+ // CHECKSTYLE:OFF
+ } catch (RuntimeException e) {
+ // CHECKSTYLE:ON
super.setOpen(true);
close(new SubProgressMonitor(monitor, 10));
throw e;
@@ -1190,7 +1191,9 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
notifyListeners(SessionListener.CLOSING);
disableAndRemoveECrossReferenceAdapters();
- removeListener(getRefreshEditorsListener());
+ if (getRefreshEditorsListener() != null) {
+ removeListener(getRefreshEditorsListener());
+ }
refreshEditorsListeners = null;
reloadingPolicy = null;
savingPolicy = null;
@@ -1215,14 +1218,17 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
currentResourceCollector = null;
}
interpreter = null;
- representationNameListener.dispose();
- representationNameListener = null;
+ if (representationNameListener != null) {
+ representationNameListener.dispose();
+ representationNameListener = null;
+ }
representationsChangeAdapter = null;
// dispose the SessionEventBroker
if (broker != null) {
broker.dispose();
broker = null;
}
+
flushOperations(transactionalEditingDomain);
// Unload all referenced resources
unloadAllResources();
@@ -1335,8 +1341,7 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
} catch (final IllegalStateException e) {
// we might have an exception unloading a resource already
// unaccessible
- SiriusPlugin.getDefault().getLog()
- .log(new Status(IStatus.WARNING, SiriusPlugin.ID, MessageFormat.format(Messages.DAnalysisSessionImpl_unloadingErrorMsg, e.getMessage()), e));
+ SiriusPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, SiriusPlugin.ID, MessageFormat.format(Messages.DAnalysisSessionImpl_unloadingErrorMsg, e.getMessage()), e));
}
rs.getResources().remove(res);
}

Back to the top