Skip to content

Package: GenModelEditor

GenModelEditor

nameinstructionbranchcomplexitylinemethod
GenModelEditor()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createTreeMasterDetail(Composite, Object, CreateElementCallback)
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getEditorTitle()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
modifyEditorInput(ResourceSet)
M: 0 C: 32
100%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 0 C: 6
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Clemens Elflein - initial API and implementation
13: * Johannes Faltermeier - reconcile genmodel
14: * Martin Fleck - bug 495190: add tree-master-detail customization
15: ******************************************************************************/
16: package org.eclipse.emfforms.internal.editor.genmodel;
17:
18: import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
19: import org.eclipse.emf.common.notify.Notifier;
20: import org.eclipse.emf.ecore.resource.Resource;
21: import org.eclipse.emf.ecore.resource.ResourceSet;
22: import org.eclipse.emfforms.spi.editor.GenericEditor;
23: import org.eclipse.emfforms.spi.swt.treemasterdetail.TreeMasterDetailComposite;
24: import org.eclipse.emfforms.spi.swt.treemasterdetail.TreeMasterDetailSWTFactory;
25: import org.eclipse.emfforms.spi.swt.treemasterdetail.util.CreateElementCallback;
26: import org.eclipse.swt.SWT;
27: import org.eclipse.swt.widgets.Composite;
28:
29: /**
30: * The Genmodel Editor.
31: *
32: * @author Clemens Elflein
33: * @author Johannes Faltermeier
34: */
35: public class GenModelEditor extends GenericEditor {
36:
37:         @Override
38:         public String getEditorTitle() {
39:                 return Messages.GenModelEditor_editorTitle;
40:         }
41:
42:         @Override
43:         protected Object modifyEditorInput(ResourceSet resourceSet) {
44:                 final Resource resource = resourceSet.getResources().get(0);
45:•                if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof GenModel) {
46:                         final GenModel genModel = (GenModel) resource.getContents().get(0);
47:                         genModel.reconcile();
48:                         genModel.setCanGenerate(true);
49:                 }
50:                 return super.modifyEditorInput(resourceSet);
51:         }
52:
53:         @SuppressWarnings("restriction")
54:         @Override
55:         protected TreeMasterDetailComposite createTreeMasterDetail(Composite composite, Object editorInput,
56:                 CreateElementCallback createElementCallback) {
57:                 final GenModelEditorTMDCustomization buildBehaviour = new GenModelEditorTMDCustomization(createElementCallback,
58:                         (Notifier) editorInput);
59:                 buildBehaviour.setTree(createTreeViewerBuilder());
60:                 return TreeMasterDetailSWTFactory.createTreeMasterDetail(composite, SWT.NONE, editorInput,
61:                         buildBehaviour);
62:         }
63:
64: }