[570295] Extended Typed instance viewer for cfb and subapp

It was possible to use direct edit for names within FBs and to edit the
name or comment within the property sheet.

Conflicts:
	plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/impl/FBNetworkElementImpl.java

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570295
Change-Id: Id5171458d7420602ac06ed4e20dc7e10326982c9
Signed-off-by: mjger<michael.oberlehner@jku.at>
diff --git a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/InstanceNameEditPart.java b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/InstanceNameEditPart.java
index 0bae452..7da0ab9 100644
--- a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/InstanceNameEditPart.java
+++ b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/InstanceNameEditPart.java
@@ -69,8 +69,8 @@
 	private final Adapter contentAdapter = new AdapterImpl() {
 
 		@Override
-		public void notifyChanged(Notification notification) {
-			Object feature = notification.getFeature();
+		public void notifyChanged(final Notification notification) {
+			final Object feature = notification.getFeature();
 			if (LibraryElementPackage.eINSTANCE.getINamedElement_Name().equals(feature)) {
 				refreshValue();
 			}
@@ -92,6 +92,7 @@
 		return (InstanceNameFigure) super.getFigure();
 	}
 
+
 	@Override
 	protected void createEditPolicies() {
 		// FBNetwork elements need a special rename command therefore we remove the
@@ -99,7 +100,7 @@
 		removeEditPolicy(EditPolicy.DIRECT_EDIT_ROLE);
 		installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new AbstractViewRenameEditPolicy() {
 			@Override
-			protected Command getDirectEditCommand(DirectEditRequest request) {
+			protected Command getDirectEditCommand(final DirectEditRequest request) {
 				if (getHost() instanceof InstanceNameEditPart) {
 					return new ChangeFBNetworkElementName(((InstanceNameEditPart) getHost()).getModel().getRefElement(),
 							(String) request.getCellEditor().getValue());
@@ -116,7 +117,7 @@
 
 	@Override
 	protected IFigure createFigure() {
-		InstanceNameFigure figure = new InstanceNameFigure();
+		final InstanceNameFigure figure = new InstanceNameFigure();
 		if (isResoruceTypeFBNElement()) {
 			figure.setIcon(FordiacImage.ICON_LOCKED_STATE.getImage());
 		}
@@ -128,7 +129,8 @@
 		// REQ_DIRECT_EDIT -> first select 0.4 sec pause -> click -> edit
 		// REQ_OPEN -> doubleclick
 
-		if (request.getType() == RequestConstants.REQ_DIRECT_EDIT || request.getType() == RequestConstants.REQ_OPEN) {
+		if (!getModel().getRefElement().isContainedInTypedInstance() && (request.getType() == RequestConstants.REQ_DIRECT_EDIT
+				|| request.getType() == RequestConstants.REQ_OPEN)) {
 			performDirectEdit();
 
 		} else {
@@ -156,22 +158,22 @@
 	}
 
 	@Override
-	public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+	public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection) {
 		return null;
 	}
 
 	@Override
-	public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+	public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection) {
 		return null;
 	}
 
 	@Override
-	public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+	public ConnectionAnchor getSourceConnectionAnchor(final Request request) {
 		return null;
 	}
 
 	@Override
-	public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+	public ConnectionAnchor getTargetConnectionAnchor(final Request request) {
 		return null;
 	}
 
diff --git a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/properties/InterfaceSection.java b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/properties/InterfaceSection.java
index cce56b3..a13aa76 100644
--- a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/properties/InterfaceSection.java
+++ b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/properties/InterfaceSection.java
@@ -20,6 +20,8 @@
 import org.eclipse.fordiac.ide.model.libraryElement.FBNetwork;
 import org.eclipse.fordiac.ide.model.libraryElement.FBNetworkElement;
 import org.eclipse.gef.EditPart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
 
 public class InterfaceSection extends AbstractInterfaceSection {
 
@@ -39,4 +41,17 @@
 		return null;
 	}
 
+	@Override
+	public void setInput(final IWorkbenchPart part, final ISelection selection) {
+		super.setInput(part, selection);
+		if (getType().isContainedInTypedInstance()) {
+			disableAllFields();
+		}
+	}
+
+	@Override
+	protected FBNetworkElement getType() {
+		return (FBNetworkElement) super.getType();
+	}
+
 }
diff --git a/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/src/org/eclipse/fordiac/ide/fbtypeeditor/network/viewer/CompositeNetworkViewerEditPart.java b/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/src/org/eclipse/fordiac/ide/fbtypeeditor/network/viewer/CompositeNetworkViewerEditPart.java
index 2322a24..b20b5dd 100644
--- a/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/src/org/eclipse/fordiac/ide/fbtypeeditor/network/viewer/CompositeNetworkViewerEditPart.java
+++ b/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/src/org/eclipse/fordiac/ide/fbtypeeditor/network/viewer/CompositeNetworkViewerEditPart.java
@@ -108,4 +108,9 @@
 		});
 	}
 
+	@Override
+	public void performRequest(final Request request) {
+		// do nothing as this is a viewer
+	}
+
 }
diff --git a/plugins/org.eclipse.fordiac.ide.gef/src/org/eclipse/fordiac/ide/gef/properties/AbstractInterfaceSection.java b/plugins/org.eclipse.fordiac.ide.gef/src/org/eclipse/fordiac/ide/gef/properties/AbstractInterfaceSection.java
index f0e25f1..696d188 100644
--- a/plugins/org.eclipse.fordiac.ide.gef/src/org/eclipse/fordiac/ide/gef/properties/AbstractInterfaceSection.java
+++ b/plugins/org.eclipse.fordiac.ide.gef/src/org/eclipse/fordiac/ide/gef/properties/AbstractInterfaceSection.java
@@ -91,8 +91,8 @@
 		createInputInfoGroup(parent);
 	}
 
-	protected void createFBInfoGroup(Composite parent) {
-		Composite composite = getWidgetFactory().createComposite(parent);
+	protected void createFBInfoGroup(final Composite parent) {
+		final Composite composite = getWidgetFactory().createComposite(parent);
 		composite.setLayout(new GridLayout(4, false));
 		composite.setLayoutData(new GridData(SWT.FILL, 0, true, false));
 		getWidgetFactory().createCLabel(composite, FordiacMessages.InstanceName + ":"); //$NON-NLS-1$
@@ -112,8 +112,8 @@
 
 	}
 
-	private void createInputInfoGroup(Composite parent) {
-		Group inputGroup = getWidgetFactory().createGroup(parent, FordiacMessages.Inputs);
+	private void createInputInfoGroup(final Composite parent) {
+		final Group inputGroup = getWidgetFactory().createGroup(parent, FordiacMessages.Inputs);
 		inputGroup.setLayout(new GridLayout(1, false));
 		inputGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
@@ -126,13 +126,13 @@
 	}
 
 	private void configureTableLayout(final Table table) {
-		TableColumn column1 = new TableColumn(inputViewer.getTable(), SWT.LEFT);
+		final TableColumn column1 = new TableColumn(inputViewer.getTable(), SWT.LEFT);
 		column1.setText(NAME_PROPERTY);
-		TableColumn column2 = new TableColumn(inputViewer.getTable(), SWT.LEFT);
+		final TableColumn column2 = new TableColumn(inputViewer.getTable(), SWT.LEFT);
 		column2.setText(VALUE_PROPERTY);
-		TableColumn column3 = new TableColumn(inputViewer.getTable(), SWT.LEFT);
+		final TableColumn column3 = new TableColumn(inputViewer.getTable(), SWT.LEFT);
 		column3.setText(COMMENT_PROPERTY);
-		TableLayout layout = new TableLayout();
+		final TableLayout layout = new TableLayout();
 		layout.addColumnData(new ColumnWeightData(20, 70));
 		layout.addColumnData(new ColumnWeightData(30, 70));
 		layout.addColumnData(new ColumnWeightData(50, 90));
@@ -142,29 +142,34 @@
 		inputViewer.setColumnProperties(new String[] { NAME_PROPERTY, VALUE_PROPERTY, COMMENT_PROPERTY });
 	}
 
-	private static String getVarDeclarationValue(VarDeclaration v) {
+	private static String getVarDeclarationValue(final VarDeclaration v) {
 		return (v.getValue() != null) ? v.getValue().getValue() : ""; //$NON-NLS-1$
 	}
 
 	@Override
 	public void setInput(final IWorkbenchPart part, final ISelection selection) {
 		Assert.isTrue(selection instanceof IStructuredSelection);
-		Object input = ((IStructuredSelection) selection).getFirstElement();
+		final Object input = ((IStructuredSelection) selection).getFirstElement();
 		commandStack = getCommandStack(part, input);
-		if (null == commandStack) { // disable all fields
-			nameText.setEnabled(false);
-			commentText.setEnabled(false);
-			inputViewer.setCellModifier(null);
+		if (null == commandStack) {
+			disableAllFields();
 		}
 		setType(input);
 	}
 
+	protected void disableAllFields() {
+		nameText.setEnabled(false);
+		commentText.setEnabled(false);
+		inputViewer.setCellModifier(null);
+	}
+
+
 	@Override
 	public void refresh() {
 		if (null != type) {
 			Display.getDefault().asyncExec(() -> {
 				if (!nameText.isDisposed() && !nameText.getParent().isDisposed()) {
-					CommandStack commandStackBuffer = commandStack;
+					final CommandStack commandStackBuffer = commandStack;
 					commandStack = null;
 					if (type instanceof AdapterFB) {
 						nameText.setEnabled(false);
@@ -178,8 +183,8 @@
 		}
 	}
 
-	private ChangeNameCommand getRenameCommand(String newValue) {
-		INamedElement element = getType();
+	private ChangeNameCommand getRenameCommand(final String newValue) {
+		final INamedElement element = getType();
 		if (element instanceof FBNetworkElement) {
 			return new ChangeFBNetworkElementName((FBNetworkElement) element, newValue);
 		}
@@ -206,8 +211,8 @@
 
 		@Override
 		public void modify(final Object element, final String property, final Object value) {
-			TableItem tableItem = (TableItem) element;
-			Object data = tableItem.getData();
+			final TableItem tableItem = (TableItem) element;
+			final Object data = tableItem.getData();
 			Command cmd = null;
 			switch (property) {
 			case VALUE_PROPERTY:
diff --git a/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeFBNetworkElementName.java b/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeFBNetworkElementName.java
index 1dae1f9..1b4f6f3 100644
--- a/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeFBNetworkElementName.java
+++ b/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeFBNetworkElementName.java
@@ -18,12 +18,17 @@
 
 public class ChangeFBNetworkElementName extends AbstractChangeElementNameWithOppositeCommand {
 
-	public ChangeFBNetworkElementName(FBNetworkElement element, String name) {
+	public ChangeFBNetworkElementName(final FBNetworkElement element, final String name) {
 		super(element, name);
 	}
 
 	@Override
-	protected INamedElement getOppositeElement(INamedElement element) {
+	public boolean canExecute() {
+		return super.canExecute() && !((FBNetworkElement) getElement()).isContainedInTypedInstance();
+	}
+
+	@Override
+	protected INamedElement getOppositeElement(final INamedElement element) {
 		if (((FBNetworkElement) element).isMapped()) {
 			return ((FBNetworkElement) element).getOpposite();
 		}
diff --git a/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeNameCommand.java b/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeNameCommand.java
index c874664..2f737c0 100644
--- a/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeNameCommand.java
+++ b/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeNameCommand.java
@@ -61,7 +61,7 @@
 		setName(name);
 	}
 
-	private void setName(String name) {
+	private void setName(final String name) {
 		element.setName(name);
 		if (null != fbNetworkElement) {
 			fbNetworkElement.setName(name);
@@ -71,4 +71,8 @@
 		}
 	}
 
+	protected INamedElement getElement() {
+		return element;
+	}
+
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.fordiac.ide.model/model/fordiac.genmodel b/plugins/org.eclipse.fordiac.ide.model/model/fordiac.genmodel
index 56a30f2..d27d142 100644
--- a/plugins/org.eclipse.fordiac.ide.model/model/fordiac.genmodel
+++ b/plugins/org.eclipse.fordiac.ide.model/model/fordiac.genmodel
@@ -306,6 +306,8 @@
           body="final EObject parent = this.eContainer();if (parent == null) {return false;}final EObject grandParent = parent.eContainer();if (grandParent == null) {return false;}return grandParent instanceof org.eclipse.fordiac.ide.model.libraryElement.SubApp;"/>
       <genOperations ecoreOperation="lib.ecore#//FBNetworkElement/getOuterFBNetworkElement"
           body="&#x9;&#x9;if ((this.eContainer() == null) || !(this.eContainer().eContainer() instanceof FBNetworkElement)) {&#xA;&#x9;&#x9;&#x9;return null;&#xA;&#x9;&#x9;}&#xA;&#x9;&#x9;return (FBNetworkElement) this.eContainer().eContainer();"/>
+      <genOperations ecoreOperation="lib.ecore#//FBNetworkElement/isContainedInTypedInstance"
+          body="return org.eclipse.fordiac.ide.model.helpers.FBNetworkElementHelper.isContainedInTypedInstance(this);"/>
     </genClasses>
     <genClasses ecoreClass="lib.ecore#//SubApp">
       <genFeatures notify="false" children="true" createChild="false" propertySortChoices="true"
diff --git a/plugins/org.eclipse.fordiac.ide.model/model/lib.ecore b/plugins/org.eclipse.fordiac.ide.model/model/lib.ecore
index 7d8c7f0..cfc142d 100644
--- a/plugins/org.eclipse.fordiac.ide.model/model/lib.ecore
+++ b/plugins/org.eclipse.fordiac.ide.model/model/lib.ecore
@@ -419,6 +419,11 @@
         <details key="body" value="&#x9;&#x9;if ((this.eContainer() == null) || !(this.eContainer().eContainer() instanceof FBNetworkElement)) {&#xA;&#x9;&#x9;&#x9;return null;&#xA;&#x9;&#x9;}&#xA;&#x9;&#x9;return (FBNetworkElement) this.eContainer().eContainer();"/>
       </eAnnotations>
     </eOperations>
+    <eOperations name="isContainedInTypedInstance" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Boolean">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="body" value="return org.eclipse.fordiac.ide.model.helpers.FBNetworkElementHelper.isContainedInTypedInstance(this);"/>
+      </eAnnotations>
+    </eOperations>
     <eStructuralFeatures xsi:type="ecore:EReference" name="interface" eType="#//InterfaceList"
         containment="true"/>
     <eStructuralFeatures xsi:type="ecore:EReference" name="mapping" eType="#//Mapping"/>
diff --git a/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/FBNetworkElement.java b/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/FBNetworkElement.java
index aaec463..00d2370 100644
--- a/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/FBNetworkElement.java
+++ b/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/FBNetworkElement.java
@@ -127,4 +127,10 @@
 	 * @generated */
 	FBNetworkElement getOuterFBNetworkElement();
 
+	/** <!-- begin-user-doc --> <!-- end-user-doc -->
+	 * 
+	 * @model kind="operation" dataType="org.eclipse.emf.ecore.xml.type.Boolean"
+	 * @generated */
+	boolean isContainedInTypedInstance();
+
 } // FBNetworkElement
diff --git a/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/impl/FBNetworkElementImpl.java b/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/impl/FBNetworkElementImpl.java
index 84c91bc..a876c16 100644
--- a/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/impl/FBNetworkElementImpl.java
+++ b/plugins/org.eclipse.fordiac.ide.model/src-gen/org/eclipse/fordiac/ide/model/libraryElement/impl/FBNetworkElementImpl.java
@@ -47,7 +47,6 @@
 public class FBNetworkElementImpl extends TypedConfigureableObjectImpl implements FBNetworkElement {
 	/** The cached value of the '{@link #getPosition() <em>Position</em>}' reference. <!-- begin-user-doc --> <!--
 	 * end-user-doc -->
-	 * 
 	 * @see #getPosition()
 	 * @generated
 	 * @ordered */
@@ -55,7 +54,6 @@
 
 	/** The cached value of the '{@link #getInterface() <em>Interface</em>}' containment reference. <!-- begin-user-doc
 	 * --> <!-- end-user-doc -->
-	 * 
 	 * @see #getInterface()
 	 * @generated
 	 * @ordered */
@@ -63,7 +61,6 @@
 
 	/** The cached value of the '{@link #getMapping() <em>Mapping</em>}' reference. <!-- begin-user-doc --> <!--
 	 * end-user-doc -->
-	 * 
 	 * @see #getMapping()
 	 * @generated
 	 * @ordered */
@@ -347,7 +344,7 @@
 	}
 
 	/** <!-- begin-user-doc --> <!-- end-user-doc -->
-	 * 
+	 *
 	 * @generated */
 	@Override
 	public void updatePosition(final Point newPos) {
@@ -358,6 +355,14 @@
 	 *
 	 * @generated */
 	@Override
+	public boolean isContainedInTypedInstance() {
+		return org.eclipse.fordiac.ide.model.helpers.FBNetworkElementHelper.isContainedInTypedInstance(this);
+	}
+
+	/** <!-- begin-user-doc --> <!-- end-user-doc -->
+	 *
+	 * @generated */
+	@Override
 	public NotificationChain eInverseRemove(final InternalEObject otherEnd, final int featureID,
 			final NotificationChain msgs) {
 		switch (featureID) {
diff --git a/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/helpers/FBNetworkElementHelper.java b/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/helpers/FBNetworkElementHelper.java
new file mode 100644
index 0000000..0e6e7da
--- /dev/null
+++ b/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/helpers/FBNetworkElementHelper.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Primetals Technologies Austria GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   Michael Oberlehner - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.fordiac.ide.model.helpers;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.fordiac.ide.model.Palette.PaletteEntry;
+import org.eclipse.fordiac.ide.model.libraryElement.CompositeFBType;
+import org.eclipse.fordiac.ide.model.libraryElement.FBNetworkElement;
+import org.eclipse.fordiac.ide.model.libraryElement.LibraryElement;
+import org.eclipse.fordiac.ide.model.typelibrary.TypeLibrary;
+import org.eclipse.fordiac.ide.ui.editors.EditorUtils;
+import org.eclipse.ui.IEditorInput;
+
+public class FBNetworkElementHelper {
+
+	public static boolean isContainedInTypedInstance(final FBNetworkElement element) {
+		switch (EditorUtils.getEditorKind()) {
+		case TYPE_EDITOR:
+			return handleTypeEditor(element);
+		case AUTOMATION_SYSTEM_EDITOR:
+			return handleAutomationSystemEditor(element);
+		default:
+			return false;
+
+		}
+	}
+
+	private static boolean handleAutomationSystemEditor(final FBNetworkElement element) {
+		return isInSubAppType(element);
+	}
+
+	private static boolean isInSubAppType(final FBNetworkElement element) {
+		EObject obj = element;
+		while (obj.eContainer() != null) {
+			obj = obj.eContainer();
+			if (obj instanceof CompositeFBType) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	private static boolean handleTypeEditor(final FBNetworkElement element) {
+
+		final IEditorInput editorInput = EditorUtils.getCurrentActiveEditor().getEditorInput();
+		final EObject rootContainer = EcoreUtil.getRootContainer(element);
+
+		if (rootContainer instanceof CompositeFBType) {
+			final IFile typeFile = editorInput.getAdapter(IFile.class);
+			final PaletteEntry paletteEntryForFile = TypeLibrary.getPaletteEntryForFile(typeFile);
+			final LibraryElement type = paletteEntryForFile.getType();
+			if (rootContainer.equals(type)) {
+				return false;
+			}
+		}
+
+		return isInSubAppType(element);
+	}
+
+}
diff --git a/plugins/org.eclipse.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/editors/EditorUtils.java b/plugins/org.eclipse.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/editors/EditorUtils.java
index d19b19a..ee39820 100644
--- a/plugins/org.eclipse.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/editors/EditorUtils.java
+++ b/plugins/org.eclipse.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/editors/EditorUtils.java
@@ -1,7 +1,7 @@
 /*******************************************************************************
  * Copyright (c) 2016 fortiss GmbH
  * 				 2019 Johannes Kepler University Linz
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
@@ -10,8 +10,8 @@
  *
  * Contributors:
  *   Alois Zoitl - initial API and implementation and/or initial documentation
- *   Alois Zoitl - moved getCurrentActiveEditor and openEditor helper functions 
- *   			   to EditorUtils  
+ *   Alois Zoitl - moved getCurrentActiveEditor and openEditor helper functions
+ *   			   to EditorUtils
  *******************************************************************************/
 package org.eclipse.fordiac.ide.ui.editors;
 
@@ -26,7 +26,11 @@
 
 public final class EditorUtils {
 
-	public static final EditorAction CloseEditor = (IEditorPart part) -> PlatformUI.getWorkbench()
+	public enum EditorKind {
+		TYPE_EDITOR, AUTOMATION_SYSTEM_EDITOR, NONE
+	}
+
+	public static final EditorAction CloseEditor = (final IEditorPart part) -> PlatformUI.getWorkbench()
 			.getActiveWorkbenchWindow().getActivePage().closeEditor(part, false);
 
 	private EditorUtils() {
@@ -34,19 +38,19 @@
 	}
 
 	public static IEditorPart getCurrentActiveEditor() {
-		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+		final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 		if (window != null && window.getActivePage() != null) {
 			return window.getActivePage().getActiveEditor();
 		}
 		return null;
 	}
 
-	public static IEditorPart openEditor(IEditorInput input, String editorId) {
+	public static IEditorPart openEditor(final IEditorInput input, final String editorId) {
 		IEditorPart editor = null;
-		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+		final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 		try {
 			editor = activePage.openEditor(input, editorId);
-		} catch (PartInitException e) {
+		} catch (final PartInitException e) {
 			editor = null;
 			UIPlugin.getDefault().logError(e.getMessage(), e);
 		}
@@ -54,11 +58,11 @@
 	}
 
 	public static IEditorPart findEditor(final EditorFilter filter) {
-		IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+		final IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
 				.getEditorReferences();
 
-		for (IEditorReference editorReference : editorReferences) {
-			IEditorPart editor = editorReference.getEditor(false);
+		for (final IEditorReference editorReference : editorReferences) {
+			final IEditorPart editor = editorReference.getEditor(false);
 			if (null != editor && filter.filter(editor)) {
 				return editor;
 			}
@@ -67,11 +71,11 @@
 	}
 
 	public static void forEachOpenEditorFiltered(final EditorFilter filter, final EditorAction action) {
-		IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+		final IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
 				.getEditorReferences();
 
-		for (IEditorReference editorReference : editorReferences) {
-			IEditorPart editor = editorReference.getEditor(false);
+		for (final IEditorReference editorReference : editorReferences) {
+			final IEditorPart editor = editorReference.getEditor(false);
 			if (null != editor && filter.filter(editor)) {
 				action.run(editor);
 			}
@@ -81,4 +85,23 @@
 	public static void closeEditorsFiltered(final EditorFilter filter) {
 		forEachOpenEditorFiltered(filter, CloseEditor);
 	}
+
+	public static EditorKind getEditorKind() {
+		final IEditorPart currentActiveEditor = getCurrentActiveEditor();
+		if (currentActiveEditor == null) {
+			return EditorKind.NONE;
+		}
+		final String editorName = currentActiveEditor.getClass().getSimpleName();
+		switch (editorName) {
+		case "SubAppTypeEditor": //$NON-NLS-1$
+		case "FBTypeEditor"://$NON-NLS-1$
+			return EditorKind.TYPE_EDITOR;
+		case "AutomationSystemEditor"://$NON-NLS-1$
+			return EditorKind.AUTOMATION_SYSTEM_EDITOR;
+		default:
+			return EditorKind.NONE;
+		}
+
+	}
+
 }