]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ProceduralComponentTypeCodeEditor.java
Fix change of type in component property editor when range is present
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / ProceduralComponentTypeCodeEditor.java
1 /*******************************************************************************
2  * Copyright (c) 2013, 2015 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *     Semantum Oy - adaption to SCLModuleEditor/TextEditor
12  *******************************************************************************/
13 package org.simantics.modeling.ui.componentTypeEditor;
14
15 import org.eclipse.swt.widgets.Display;
16 import org.eclipse.ui.PlatformUI;
17 import org.simantics.db.common.request.ParametrizedRead;
18 import org.simantics.db.layer0.request.combinations.Combinators;
19 import org.simantics.layer0.Layer0;
20 import org.simantics.scl.ui.editor.SCLSourceViewerConfigurationNew;
21 import org.simantics.scl.ui.editor.SharedTextColorsNew;
22 import org.simantics.ui.workbench.IResourceEditorInput;
23 import org.simantics.ui.workbench.editor.input.InputValidationCombinators;
24
25 /**
26  * @author Hannu Niemistö
27  * @author Tuukka Lehtonen (extended from SCLModuleEditor)
28  */
29 public class ProceduralComponentTypeCodeEditor extends SCLModuleEditor {
30
31     private ParametrizedRead<IResourceEditorInput, Boolean> INPUT_VALIDATOR =
32             Combinators.compose(
33                     InputValidationCombinators.hasURI(),
34                     Combinators.compose(
35                             InputValidationCombinators.partialFunction(Layer0.URIs.PropertyOf),
36                             InputValidationCombinators.extractInputResource()
37                     )
38             );
39
40     public ProceduralComponentTypeCodeEditor() {
41         super();
42     }
43
44     @Override
45     protected void preInitialize() {
46         //showOverviewRuler();
47         Display display = PlatformUI.getWorkbench().getDisplay();
48         SCLSourceViewerConfigurationNew sourceViewerConfiguration = new SCLSourceViewerConfigurationNew(resourceManager);
49         setDocumentProvider(new ProceduralComponentTypeCodeDocumentProvider(sourceViewerConfiguration, display, this));
50         setSourceViewerConfiguration(sourceViewerConfiguration);
51         
52     }
53
54     protected ParametrizedRead<IResourceEditorInput, Boolean> getInputValidator() {
55         return INPUT_VALIDATOR;
56     }
57
58 }