Skip to content
Snippets Groups Projects
Commit c87dc9a3 authored by Simon Barner's avatar Simon Barner
Browse files

Introduce "ModelEditorNotAvailableBinding"

  - It can be used to specify that for a particular model element no editor is available.
  - This avoids that ModelEditorBindingService further walks up the model hierarchy to look for an editor that is registered for one of the ancestors. Currently, this had the the effect that for a model element without explicit editor, the project configuration editor (that is registered for the root element "FileProject") has been opened

Use the the new ModelEditorNotAvailableBinding mechanism for the following model elements
  - SystemSchedule
  - AllocationTableCollection
  - SafetyArgumentationPackage
refs 3048
parent e79d8798
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2017 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.extension;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
* A special model editor binding that can be used to indicate that for some model element type no
* editor is available.
*
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 7832967A672B8DA3E9DA3EC5F619AF2E
*/
public final class ModelEditorNotAvailableBinding extends ModelEditorBindingBase<EObject> {
// Nothing to do: The type ModelEditorNotAvailableBinding is used in ModelEditorBindingService
// to make a case distinction for model elements without dedicated editors.
}
......@@ -51,6 +51,7 @@ import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.ui.extension.IModelEditor;
import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.ModelEditorNotAvailableBinding;
import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelEditorBindingServiceIntrospectionDetailsItem;
......@@ -65,7 +66,7 @@ import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: E0A5099E95B68D133185FE1231BD04D5
* @ConQAT.Rating YELLOW Hash: 4C9FA5C29DE00AF287B1AA1F131BB2A5
*/
public class ModelEditorBindingService extends
EObjectAwareServiceBase<IModelEditorBinding<EObject>> implements
......@@ -122,6 +123,7 @@ public class ModelEditorBindingService extends
/** {@inheritDoc} */
@Override
public void openInEditor(EObject element) {
// TODO (SB,13): Where does the "2" come from? See #3048
openInEditor(element, 2);
}
......@@ -145,7 +147,16 @@ public class ModelEditorBindingService extends
}
return;
}
if(getBindings(element).isEmpty()) {
List<IModelEditorBinding<EObject>> bindings = getBindings(element);
int numBindings = bindings.size();
// There is exactly one binding that indicates that no editor should be displayed.
if(numBindings == 1 && bindings.get(0) instanceof ModelEditorNotAvailableBinding) {
return;
}
// Recurse if there is an editor for one the model element's ancestors.
if(numBindings == 0) {
if(depth > 0 && element.eContainer() != null) {
openInEditor(element.eContainer(), depth - 1);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment