Search in sources :

Example 1 with IArchimateDiagramEditor

use of com.archimatetool.editor.diagram.IArchimateDiagramEditor in project archi by archimatetool.

the class TreeViewpointFilterProvider method partActivated.

@Override
public void partActivated(IWorkbenchPart part) {
    /*
         * Refresh Tree only if an IEditorPart is activated.
         * 
         * If we call refresh() when a ViewPart is activated then a problem occurs when:
         * 1. User adds a new Diagram View to the Tree
         * 2. Element is added to model - refresh() is called on Tree
         * 3. Diagram Editor is opened and activated
         * 4. This is notified of Diagram Editor Part activation and calls refresh() on Tree
         * 5. NewDiagramCommand.execute() calls TreeModelViewer.editElement() to edit the cell name
         * 6. The Tree is then activated and This is notified of Diagram Editor Part activation and calls refresh() on Tree
         * 7. TreeModelViewer.refresh(element) then cancels editing
         */
    if (part instanceof IEditorPart) {
        IArchimateDiagramModel previous = fActiveDiagramModel;
        // Archimate editor
        if (part instanceof IArchimateDiagramEditor) {
            IArchimateDiagramModel dm = (IArchimateDiagramModel) ((IArchimateDiagramEditor) part).getModel();
            if (previous == dm) {
                return;
            }
            fActiveDiagramModel = dm;
        } else // Other type of editor (sketch, canvas)
        {
            fActiveDiagramModel = null;
        }
        // Refresh previous model
        refreshTreeModel(previous);
        // Refresh selected model
        refreshTreeModel(fActiveDiagramModel);
    }
}
Also used : IArchimateDiagramEditor(com.archimatetool.editor.diagram.IArchimateDiagramEditor) IEditorPart(org.eclipse.ui.IEditorPart) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Aggregations

IArchimateDiagramEditor (com.archimatetool.editor.diagram.IArchimateDiagramEditor)1 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)1 IEditorPart (org.eclipse.ui.IEditorPart)1