/*******************************************************************************
- * Copyright (c) 2013, 2015 Association for Decentralized Information Management in
+ * Copyright (c) 2013, 2019 Association for Decentralized Information Management in
* Industry THTH ry.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
import org.simantics.Simantics;
import org.simantics.databoard.Bindings;
import org.simantics.db.ReadGraph;
import org.simantics.db.common.request.ParametrizedRead;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.common.request.UniqueRead;
-import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.request.combinations.Combinators;
import org.simantics.db.request.Read;
@Override
protected void preInitialize() {
setDocumentProvider(new ComponentTypeScriptDocumentProvider(this));
- Display display = PlatformUI.getWorkbench().getDisplay();
SCLSourceViewerConfigurationNew sourceViewerConfiguration = new SCLSourceViewerConfigurationNew(resourceManager);
setSourceViewerConfiguration(sourceViewerConfiguration);
"post-step", //$NON-NLS-1$
"analogAutomation", //$NON-NLS-1$
"binaryAutomation", //$NON-NLS-1$
- "preparation" //$NON-NLS-1$
+ "preparation", //$NON-NLS-1$
+ "post-preparation" //$NON-NLS-1$
};
private static final String[] EXECUTION_PHASE_LABELS = new String[] {
Messages.ComponentTypeScriptEditor_ExecuteAfterEachStep,
Messages.ComponentTypeScriptEditor_ExecuteAnalogAutomation,
Messages.ComponentTypeScriptEditor_ExecuteBinaryAutomation,
- Messages.ComponentTypeScriptEditor_ExecuteDuringPreparation
+ Messages.ComponentTypeScriptEditor_ExecuteBeforePreparation,
+ Messages.ComponentTypeScriptEditor_ExecuteAfterPreparation
};
@Override
StructuralResource2 STR = StructuralResource2.getInstance(graph);
final String type = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type);
if(type != null)
- combo.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- for(int i=0;i<EXECUTION_PHASES.length;++i)
- if(EXECUTION_PHASES[i].equals(type)) {
- combo.select(i);
- return;
- }
- }
+ combo.getDisplay().asyncExec(() -> {
+ for(int i=0;i<EXECUTION_PHASES.length;++i)
+ if(EXECUTION_PHASES[i].equals(type)) {
+ combo.select(i);
+ return;
+ }
});
}
});
}
- combo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- final int id = combo.getSelectionIndex();
- Simantics.getSession().asyncRequest(new WriteRequest() {
- @Override
- public void perform(WriteGraph graph)
- throws DatabaseException {
- StructuralResource2 STR = StructuralResource2.getInstance(graph);
- String currentType = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type);
- String newType = EXECUTION_PHASES[id];
- if(!newType.equals(currentType))
- graph.claimLiteral(script, STR.ComponentTypeScript_type, newType, Bindings.STRING);
- }
- });
- }
- });
+ combo.addSelectionListener(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter(e -> {
+ int id = combo.getSelectionIndex();
+ Simantics.getSession().asyncRequest((WriteGraph graph) -> {
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);
+ String currentType = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type);
+ String newType = EXECUTION_PHASES[id];
+ if(!newType.equals(currentType))
+ graph.claimLiteral(script, STR.ComponentTypeScript_type, newType, Bindings.STRING);
+ });
+ }));
GridDataFactory.fillDefaults().grab(true, false).applyTo(combo);
Composite editorComposite = new Composite(parent, SWT.NONE);